first_name taken from incorrect attribute 'cn'

Bug #1508147 reported by Richard Bychowski on 2015-10-20
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SchoolTool LDAP
Undecided
Unassigned

Bug Description

A user's name was bing displayed as "First Last Last" after login with LDAP credentials.
Looking at "ldap/security.py" shows that first_name is being taken from "cn" attribute,

http://tools.ietf.org/html/rfc4519#section-2.3 states:

"The 'cn' ('commonName' in X.500) attribute type contains names of an
   object. Each name is one value of this multi-valued attribute. If
   the object corresponds to a person, it is typically the person's full
   name."

The appropriate attribute is "givenName":
"The 'givenName' attribute type contains name strings that are the
   part of a person's name that is not their surname."

I suggest adding "givenName" to the "all_attrs" list, and substituting
"givenName" for "cn" in the "first_name" assignment.

class PersonLDAPPersonPart(SchoolToolLDAPObjectPart):

    all_attrs = (
        'sn', # surname
        'cn', # common name
        'givenName', # first name <== NEW LINE
        'userPassword', 'telephoneNumber', 'seeAlso', 'description')

    def __init__(self, *args, **kw):
        SchoolToolLDAPObjectPart.__init__(self, *args, **kw)

    def oneline(self, t):
        if not t:
            return u''
        return u' '.join(s.decode('UTF-8') for s in t).strip()

    def update(self):
        super(PersonLDAPPersonPart, self).update()
        self.target.person_attrs.update({
# 'first_name': self.oneline(self.data.cn), <== INCORRECT
            'first_name': self.oneline(self.data.givenName), # <== CORRECT
            'last_name': self.oneline(self.data.sn),
            })
        self.target.contact_attrs.update({
            'work_phone': self.oneline(self.data.telephoneNumber) or None,
            })

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers