Update LDAP account sync to allow for more flexibility in name attributes.
Review Request #2389 — Created June 1, 2011 and submitted
Information | |
---|---|
junk | |
Review Board | |
2122 | |
Reviewers | |
reviewboard | |
Added the following LDAP options: * LDAP_GIVEN_NAME_ATTRIBUTE * LDAP_SURNAME_ATTRIBUTE * LDAP_FULL_NAME_ATTRIBUTE 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.
-
-
reviewboard/accounts/backends.py (Diff revision 1) Might be better like: given_name_attr = settings.LDAP_GIVEN_NAME_ATTRIBUTE or 'givenName' first_name = user_info.get(given_name_attr, [username])[0]
-
reviewboard/accounts/backends.py (Diff revision 1) Here too. Shouldn't this be LDAP_SURNAME_ATTRIBUTE?
-
reviewboard/accounts/backends.py (Diff revision 1) Both of these are the same. Also, multi-line conditionals should use parens, rather than \
-
-
reviewboard/accounts/forms.py (Diff revision 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?
JU
Change Summary:
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.
Diff: |
Revision 2 (+62 -23) |
---|
-
-
reviewboard/accounts/backends.py (Diff revision 2) 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. So try: given_name_attr = getattr(settings, 'LDAP_GIVEN_NAME_ATTRIBUTE', 'givenName')
-
-