diff options
author | Martin Basti <mbasti@redhat.com> | 2014-08-27 15:06:42 +0200 |
---|---|---|
committer | Martin Kosek <mkosek@redhat.com> | 2014-09-26 13:21:15 +0200 |
commit | 29ba9d9d26b92498902d40d71adae193308b5c92 (patch) | |
tree | 9b188a66b8ff28869102fe2263dd5902916d0204 /ipaserver/install/bindinstance.py | |
parent | dea825fd9cdd36a6fa371b2a5e1d1f35c177c6ef (diff) | |
download | freeipa-29ba9d9d26b92498902d40d71adae193308b5c92.tar.gz freeipa-29ba9d9d26b92498902d40d71adae193308b5c92.tar.xz freeipa-29ba9d9d26b92498902d40d71adae193308b5c92.zip |
Refactoring of autobind, object_exists
Required to prevent code duplications
ipaldap.IPAdmin now has method do_bind, which tries several bind methods
ipaldap.IPAClient now has method object_exists(dn)
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
Diffstat (limited to 'ipaserver/install/bindinstance.py')
-rw-r--r-- | ipaserver/install/bindinstance.py | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/ipaserver/install/bindinstance.py b/ipaserver/install/bindinstance.py index 09760d667..cece85ec6 100644 --- a/ipaserver/install/bindinstance.py +++ b/ipaserver/install/bindinstance.py @@ -202,23 +202,11 @@ def named_conf_set_directive(name, value, section=NAMED_SECTION_IPA, with open(NAMED_CONF, 'w') as f: f.write("".join(new_lines)) -def dns_container_exists(fqdn, suffix, dm_password=None, ldapi=False, realm=None): +def dns_container_exists(fqdn, suffix, dm_password=None, ldapi=False, realm=None, + autobind=ipaldap.AUTOBIND_DISABLED): """ Test whether the dns container exists. """ - - def object_exists(dn): # FIXME, this should be a IPAdmin/ldap2 method so it can be shared - """ - Test whether the given object exists in LDAP. - """ - assert isinstance(dn, DN) - try: - conn.get_entry(dn) - except errors.NotFound: - return False - else: - return True - assert isinstance(suffix, DN) try: # At install time we may need to use LDAPI to avoid chicken/egg @@ -228,14 +216,11 @@ def dns_container_exists(fqdn, suffix, dm_password=None, ldapi=False, realm=None else: conn = ipaldap.IPAdmin(host=fqdn, port=636, cacert=CACERT) - if dm_password: - conn.do_simple_bind(bindpw=dm_password) - else: - conn.do_sasl_gssapi_bind() + conn.do_bind(dm_password, autobind=autobind) except ldap.SERVER_DOWN: raise RuntimeError('LDAP server on %s is not responding. Is IPA installed?' % fqdn) - ret = object_exists(DN(('cn', 'dns'), suffix)) + ret = conn.entry_exists(DN(('cn', 'dns'), suffix)) conn.unbind() return ret @@ -446,7 +431,7 @@ class BindInstance(service.Service): service_desc="DNS", dm_password=dm_password, ldapi=False, - autobind=service.DISABLED + autobind=ipaldap.AUTOBIND_DISABLED ) self.dns_backup = DnsBackup(self) self.named_user = None |