fix(ldap): ldap3 exception

A blank password causes exception 'ldap3.core.exceptions.LDAPPasswordIsMandatoryError'. Validate the user input.

Issue #13738
This commit is contained in:
Jon Lockwood 2021-07-25 17:21:28 +09:30
parent 36c5b7fa09
commit 5f6f6a77e5

View file

@ -224,7 +224,7 @@ class LDAPSettings(Document):
groups = self.fetch_ldap_groups(user, conn)
# only try and connect as the user, once we have their fqdn entry.
if conn.rebind(user=user.entry_dn, password=password):
if user.entry_dn and password and conn.rebind(user=user.entry_dn, password=password):
return self.create_or_update_user(self.convert_ldap_entry_to_dict(user), groups=groups)
raise ldap3.core.exceptions.LDAPInvalidCredentialsResult # even though nothing foundor failed authentication raise invalid credentials