first_name taken from incorrect attribute 'cn'

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

Bug Description

A user's name was bing displayed as "First Last Last" after login with LDAP credentials.
Looking at "ldap/" shows that first_name is being taken from "cn" attribute, 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

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(){
# 'first_name': self.oneline(, <== INCORRECT
            'first_name': self.oneline(, # <== CORRECT
            'last_name': self.oneline(,
            'work_phone': self.oneline( or None,

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

Other bug subscribers