mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-18 05:51:26 +02:00
ldap auth: avoid creation of duplicated identities.
This commit is contained in:
+11
-12
@@ -84,18 +84,17 @@ try:
|
||||
if grp.strip() in ldap_user.group_names:
|
||||
group = "DomainAdmins"
|
||||
break
|
||||
if group == "SimpleUsers":
|
||||
lpart, domain = split_mailbox(username)
|
||||
if domain is 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
|
||||
lpart, domain = split_mailbox(username)
|
||||
if domain is 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 and group == "SimpleUsers":
|
||||
return None
|
||||
username = email
|
||||
user, created = User.objects.get_or_create(
|
||||
username__iexact=username,
|
||||
defaults={
|
||||
|
||||
Reference in New Issue
Block a user