diff --git a/dal/ungleich_ldap.py b/dal/ungleich_ldap.py index 54e8eee..24566fa 100644 --- a/dal/ungleich_ldap.py +++ b/dal/ungleich_ldap.py @@ -74,9 +74,9 @@ class LdapManager: conn = self.get_admin_conn() uidNumber = self._get_max_uid() + 1 logger.debug("uidNumber={uidNumber}".format(uidNumber=uidNumber)) - results = True - while results: - results = self.check_user_exists( + user_exists = True + while user_exists: + user_exists, _ = self.check_user_exists( "", True, '(&(objectClass=inetOrgPerson)(objectClass=posixAccount)' @@ -84,7 +84,7 @@ class LdapManager: uidNumber=uidNumber ) ) - if results: + if user_exists: logger.debug( "{uid} exists. Trying next.".format(uid=uidNumber) ) @@ -155,15 +155,17 @@ class LdapManager: :return: True if the user exists otherwise return False """ conn = self.get_admin_conn() + entries = [] try: result = conn.search( settings.LDAP_CUSTOMER_DN if is_customer else settings.LDAP_USERS_DN, search_filter=search_filter if len(search_filter)> 0 else '(uid={uid})'.format(uid=uid) ) + entries = conn.entries finally: conn.unbind() - return result + return result, entries def _set_max_uid(self, max_uid): """