mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-25 08:21:05 -06:00
d0818e1809
Related: https://pagure.io/freeipa/issue/8306 Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Florence Blanc-Renaud <frenaud@redhat.com>
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
#
|
|
# Copyright (C) 2016 FreeIPA Contributors see COPYING for license
|
|
#
|
|
|
|
from ipalib import Registry
|
|
from ipalib import Updater
|
|
from ipalib import errors
|
|
from ipapython.dn import DN
|
|
|
|
register = Registry()
|
|
|
|
|
|
@register()
|
|
class update_ldap_server_list(Updater):
|
|
"""
|
|
Update defaultServerList, an option that helps Solaris
|
|
clients discover LDAP server replicas.
|
|
"""
|
|
def execute(self, **options):
|
|
ldap = self.api.Backend.ldap2
|
|
|
|
dn = DN(('cn', 'default'), ('ou', 'profile'), self.api.env.basedn)
|
|
try:
|
|
entry = ldap.get_entry(dn)
|
|
srvlist = entry.single_value.get('defaultServerList', '')
|
|
srvlist = srvlist.split()
|
|
if self.api.env.host not in srvlist:
|
|
srvlist.append(self.api.env.host)
|
|
attr = ' '.join(srvlist)
|
|
entry['defaultServerList'] = attr
|
|
ldap.update_entry(entry)
|
|
except errors.NotFound:
|
|
pass
|
|
except ldap.TYPE_OR_VALUE_EXISTS:
|
|
pass
|
|
|
|
# no restart, no updates
|
|
return False, ()
|