Announcement Announcement Module
Collapse
No announcement yet.
Can't set the displayName in Active Directory Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can't set the displayName in Active Directory

    Hi,
    I am trying to set the displayName in active directory but I get the following Exception:

    Code:
    org.springframework.ldap.UncategorizedLdapException: Operation failed; nested exception is javax.naming.directory.InvalidAttributeValueException: 'displayName' has no values.; remaining name 'cn=Jan Klein, ou=users, dc=xx, dc=xx, dc=xx, dc=nl'
    Caused by: javax.naming.directory.InvalidAttributeValueException: 'displayName' has no values.; remaining name 'cn=Jan Klein, ou=xxx, dc=xx, dc=xx, dc=xx, dc=nl'
    	at com.sun.jndi.ldap.LdapClient.add(Unknown Source)
    	at com.sun.jndi.ldap.LdapCtx.c_bind(Unknown Source)
    	at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_bind(Unknown Source)
    	at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.bind(Unknown Source)
    	at javax.naming.directory.InitialDirContext.bind(Unknown Source)
    	at org.springframework.ldap.LdapTemplate$21.executeWithContext(LdapTemplate.java:966)
    	at org.springframework.ldap.LdapTemplate.executeWithContext(LdapTemplate.java:762)
    	at org.springframework.ldap.LdapTemplate.executeReadWrite(LdapTemplate.java:757)
    	at org.springframework.ldap.LdapTemplate.bind(LdapTemplate.java:963)
    I'm probably using the wrong attribute name. Does anyone know what attribute name I should use. I also tried "name" as attributename but that also failes.
    The other attributes are working fine

    This is the code I use to add a user:
    Code:
    		Attributes personAttributes = new BasicAttributes();
    		BasicAttribute personBasicAttribute = new BasicAttribute("objectclass");
    		personBasicAttribute.add("inetOrgPerson");
    		personAttributes.put(personBasicAttribute);
    		personAttributes.put("cn", gebruiker.getCommonName());
    		personAttributes.put("sn", gebruiker.getLastName());
    		personAttributes.put("description", gebruiker.getDescription());
    		personAttributes.put("givenName", gebruiker.getGivenName());
    		personAttributes.put("initials", gebruiker.getInitials());
    		personAttributes.put("sAMAccountName", gebruiker.getSAMAccountName());
    		personAttributes.put("displayName", gebruiker.getDisplayName());
    		personAttributes.put("userPrincipalName", gebruiker.getUserPrincipalName());		
    		personAttributes.put("mail", gebruiker.getEmail());		
    		personAttributes.put("unicodePwd", encodePassword(gebruiker.getPassword()));//set password
    		personAttributes.put("userAccountControl", "544"); //enable account
    		DistinguishedName newContactDN = new DistinguishedName(userBaseNBML);
    		newContactDN.add("cn", gebruiker.getCommonName());
    		ldapTemplate.bind(newContactDN, null, personAttributes);
    Thanks

  • #2
    There is a "displayName" attribute in the inetOrgPerson objectclass, but I'm guessing there are some kind of restrictions on what values are valid for it (hence the InvalidAttributeValueException). I don't know the actual restrictions, but one guess would be that firstname + " " + lastname might be valid.

    Comment


    • #3
      I used firstname + " " + lastname and it worked.
      Thanks for the help

      Comment

      Working...
      X