[Plugin] auth_ldap: Fixed searching for non existing user

This commit is contained in:
Ferdinand Thiessen 2021-03-14 15:53:14 +01:00
parent 919a31bede
commit c3c35e2a6a
1 changed files with 2 additions and 2 deletions

View File

@ -54,7 +54,7 @@ class AuthLDAP(AuthPlugin):
def find_user(self, userid, mail=None):
attr = self.__find(userid, mail)
if attr:
if attr is not None:
user = User(userid=attr["uid"][0])
self.__update(user, attr)
return user
@ -186,7 +186,7 @@ class AuthLDAP(AuthPlugin):
SUBTREE,
attributes=["uid", "givenName", "sn", "mail"],
)
return con.response[0]["attributes"]
return con.response[0]["attributes"] if len(con.response) > 0 else None
def __update(self, user, attr):
"""Update an User object with LDAP attributes"""