diff options
author | Jan Cholasta <jcholast@redhat.com> | 2014-11-21 20:10:23 +0100 |
---|---|---|
committer | Jan Cholasta <jcholast@redhat.com> | 2015-04-16 06:58:31 +0000 |
commit | 232e04d861416a0b154ecda9a82e188b56eb9ba9 (patch) | |
tree | 7b31a1b9ae199d1afc7e3ae7017d2293fae3fd30 | |
parent | c904dea06afd6bbf47367ee0b17c85a821a04d65 (diff) | |
download | freeipa-232e04d861416a0b154ecda9a82e188b56eb9ba9.tar.gz freeipa-232e04d861416a0b154ecda9a82e188b56eb9ba9.tar.xz freeipa-232e04d861416a0b154ecda9a82e188b56eb9ba9.zip |
ldap: Use LDAPClient bind and unbind methods in IPAdmin
Reviewed-By: Petr Viktorin <pviktori@redhat.com>
-rw-r--r-- | ipapython/ipaldap.py | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/ipapython/ipaldap.py b/ipapython/ipaldap.py index ace1af7dd..a53fe11ce 100644 --- a/ipapython/ipaldap.py +++ b/ipapython/ipaldap.py @@ -1771,29 +1771,29 @@ class IPAdmin(LDAPClient): wait_for_open_ports(host, int(port), timeout) def __bind_with_wait(self, bind_func, timeout, *args, **kwargs): - with self.error_handler(): - try: - bind_func(*args, **kwargs) - except (ldap.CONNECT_ERROR, ldap.SERVER_DOWN), e: - if not timeout or 'TLS' in e.args[0].get('info', ''): - # No connection to continue on if we have a TLS failure - # https://bugzilla.redhat.com/show_bug.cgi?id=784989 - raise - self.__wait_for_connection(timeout) - bind_func(*args, **kwargs) + try: + bind_func(*args, **kwargs) + except errors.NetworkError as e: + if not timeout and 'TLS' in e.error: + # No connection to continue on if we have a TLS failure + # https://bugzilla.redhat.com/show_bug.cgi?id=784989 + raise + except errors.DatabaseError: + pass + else: + return + self.__wait_for_connection(timeout) + bind_func(*args, **kwargs) def do_simple_bind(self, binddn=DN(('cn', 'directory manager')), bindpw="", timeout=DEFAULT_TIMEOUT): - self.__bind_with_wait(self.conn.simple_bind_s, timeout, binddn, bindpw) + self.__bind_with_wait(self.simple_bind, timeout, binddn, bindpw) def do_sasl_gssapi_bind(self, timeout=DEFAULT_TIMEOUT): - self.__bind_with_wait( - self.conn.sasl_interactive_bind_s, timeout, None, SASL_GSSAPI) + self.__bind_with_wait(self.gssapi_bind, timeout) def do_external_bind(self, user_name=None, timeout=DEFAULT_TIMEOUT): - auth_tokens = ldap.sasl.external(user_name) - self.__bind_with_wait( - self.conn.sasl_interactive_bind_s, timeout, None, auth_tokens) + self.__bind_with_wait(self.external_bind, timeout, user_name) def do_bind(self, dm_password="", autobind=AUTOBIND_AUTO, timeout=DEFAULT_TIMEOUT): if dm_password: @@ -1817,6 +1817,3 @@ class IPAdmin(LDAPClient): def modify_s(self, *args, **kwargs): # FIXME: for backwards compatibility only return self.conn.modify_s(*args, **kwargs) - - def unbind(self, *args, **kwargs): - return self.conn.unbind_s(*args, **kwargs) |