Also return entries in the ldap search result

This commit is contained in:
PCoder 2019-02-24 14:43:24 +01:00
parent 89b535c3d6
commit 017ca767be

View file

@ -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):
"""