displayName is not adding as is into apacheds using API

447 Views Asked by At

I am using APACHE DS api to add an entry into LDAP server. However, displayName attribute is not being added as is, instead "displayname" (all small caps) is being added. Below is my entry set:

Entry entry = new DefaultEntry( 
            "cn=" + cn + "," + this.base_dn,
            "displayName",name.trim(),
            "objectclass:top",
            "objectclass:person",
            "objectclass:inetOrgPerson",
            "objectclass:organizationalPerson",
            "cn",cn,
            "sn",cn,
            "description:Gerrit User",
            "mail",cn +"@org.com",
            "userPassword",password

            );

Any idea why would this happen?

Ironically, when userPassword is mistakenly written as "userpassword", correct attribute name (which is "userPassword") gets into LDAP.

(Also, apache-ldap-api could not be found in tags below.)

2

There are 2 best solutions below

0
On BEST ANSWER

I was facing the issue because I was using gerrit in conjugation with LDAP. By default, gerrit takes ldap.accountFullName attribute as displayName for displaying the user name post login. Hence, when 'displayname' atribute was inserted into ldap, gerrit was not able to search for this attribute (gerrit case sensitivity). Changing this gerrit attribute to 'displayname' solved my purpose.

On LDAP side, attributes are CASE INSENSITIVE.

3
On

LDAP attribute names are case insensitive so 'displayname' == 'displayName' and 'userpassword' == 'userPassword'. They are functionally the same and the difference is only aesthetic. Apache DS maybe uses the name as it listed in the schema.