Skip to content

Commit

Permalink
Lowercase incoming username field
Browse files Browse the repository at this point in the history
  • Loading branch information
jbittel committed May 18, 2016
1 parent df59060 commit a0f7895
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ldap_sync/management/commands/syncldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,17 @@ def sync_ldap_users(self, ldap_users):
error_msg = ("LDAP_SYNC_USER_ATTRIBUTES must contain the field '%s'" % username_field)
raise ImproperlyConfigured(error_msg)

for cname, ldap_attributes in ldap_users:
for cname, attributes in ldap_users:
defaults = {}
try:
for name, attribute in ldap_attributes.items():
for name, attribute in attributes.items():
defaults[user_attributes[name]] = attribute[0].decode('utf-8')
except AttributeError:
# In some cases attrs is a list instead of a dict; skip these invalid users
# In some cases attributes is a list instead of a dict; skip these invalid users
continue

try:
username = defaults[username_field]
username = defaults[username_field].lower()
except KeyError:
logger.warning("User is missing a required attribute '%s'" % username_field)
continue
Expand Down

0 comments on commit a0f7895

Please sign in to comment.