Allow login with username instead of email for LDAP.

see #1798
This commit is contained in:
Antoine Nguyen
2020-02-17 15:52:32 +01:00
parent f8d5f072f8
commit 5d9ac817b2
+9 -1
View File
@@ -87,7 +87,15 @@ try:
if group == "SimpleUsers":
lpart, domain = split_mailbox(username)
if domain is None:
return None
# Try to find associated email
email = None
for attr in ['mail', 'userPrincipalName']:
if attr in ldap_user.attrs:
email = ldap_user.attrs[attr][0]
break
if email is None:
return None
username = email
user, created = User.objects.get_or_create(
username__iexact=username,
defaults={