Added the following LDAP options:
While comments made in http://reviews.reviewboard.org/r/399/ are true (sn and givenName are "standard"), they're not required or mandated to use the same naming conventions. They are listed as "good practice" and "acceptable" in the related RFCs but are up to the whim of the sysadmin building the system. Because of this, having flexibility is beneficial. None of these fields are required and the Full Name Attribute will always be ignored if a response is given for Given Name or Surname.
Tested against LDAP dev LDAP server with long names (greate than two) and changing name attributes for first_name and last_name.
Might be better like:
given_name_attr = settings.LDAP_GIVEN_NAME_ATTRIBUTE or 'givenName'
first_name = user_info.get(given_name_attr, [username])
Shouldn't this be LDAP_SURNAME_ATTRIBUTE?
Both of these are the same.
Also, multi-line conditionals should use parens, rather than \
first_name, last_name = full_name.split(' ', 1)
What are these showing when using defaults? Just empty?
Maybe instead, these should default to "givenName" and stuff, which would simplify the logic above?
Review request changed
This is why one should sleep before submitting code after long days...
Vastly simplified the change and tested with multiple cases:
* bad/missing attribute for given name
* bad/missing attribute for surname
* single entry for full name
Full Name Attribute now takes precedence.
If settings.LDAP_GIVEN_NAME_ATTRIBUTE isn't set, this will probably fail, particularly on existing setups that don't have this saved. It also won't have the 'givenName' default.
given_name_attr = getattr(settings, 'LDAP_GIVEN_NAME_ATTRIBUTE', 'givenName')