简体   繁体   中英

Add entry in openldap server using unboundid ldap sdk

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: 在此处输入图片说明

Please let me what am I doing wrong.

Thank you

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"
            };

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM