0

I was trying to add a new entry into ldap. I'm using unboundid ldap sdk I'm able to connect successfully to ldap however when I try to add new entry, I'm getting following error:

Exception in thread "main" LDAPException(resultCode=undefined attribute type, errorMessage='changetype: attribute type undefined')
at com.unboundid.ldap.sdk.LDAPConnection.add(LDAPConnection.java:1539)

Here is code snippet I used to add entry into ldap:

String[] ldifAttrs = {
            "dn: ou=people,dc=maxcrc,dc=com",
            "changetype:add",
            "cn: vipin",
            "sn: falke",
            "uid: vfalke",
            "userPassword:secret"
            };
LDAPConnection ldapConnection = new LDAPConnection("127.0.0.1", 389,
            "cn=Manager, dc=maxcrc, dc=com", "secret");
ldapConnection.add(new AddRequest(ldifAttrs));

Ldap server directory structure:enter image description here

Please let me what am I doing wrong.

Thank you

Ashok Dongare
  • 521
  • 2
  • 7
  • 20

1 Answers1

0

I think you will need to add, at least" some, I would recommend all if not all the ObjectClasses.

How else would OpenLDAP know what type of ObjectClass you wanted to add .adding?

String[] ldifAttrs = {
            "dn: ou=people,dc=maxcrc,dc=com",
            "changetype:add",
            "objectClass: top",
            "objectClass: person",
            "objectClass: organizationalPerson",
            "objectClass: inetOrgPerson",
            "cn: vipin",
            "sn: falke",
            "uid: vfalke",
            "userPassword:secret"
            };
jwilleke
  • 10,467
  • 1
  • 30
  • 51