sjkingo / django_auth_ldap3

A library for connecting Django's authentication system to an LDAP directory
BSD 2-Clause "Simplified" License
23 stars 13 forks source link

Exception raised when AD user has no email #19

Closed alandmoore closed 8 years ago

alandmoore commented 8 years ago

If no email address is specified in AD, django will throw an exception on login because the User model doesn't allow an email value of None.

In line 34 of backends.py, any missing attributes are filled in with None as a value. The default django User model allows blank for first_name, last_name, and email, so I'm wondering if it would be better to default missing attributes to an empty string.

There are legitimate cases where an AD user may not have a first name, last name, or email address specified, so it seems like the right thing to just pass that empty field on to the User object.

Thoughts?

sjkingo commented 8 years ago

Yep, I agree that passing a blank string is a better idea for those fields.

Could you create a PR and I can do some testing on OpenLDAP also.

Thanks Alan

sjkingo commented 8 years ago

Version 0.9.6 released on PyPi that incorporates the changes from #20.

Thanks Alan