Skip to Main Content

Security Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to add a custom attribute to an entry?

475232Jan 12 2006 — edited Jan 13 2006
I need to store a person's social security number in the directory.
I haven't found any appropriate standard attribute for such purpose (is there any?), so I decided to create a new one.

I've written a method:

public void setAttribute(String entryDN, String attrName, String attrValue)
throws LDAPException, UnsupportedEncodingException
{
LDAPConnection lc = new LDAPConnection();
lc.connect(ldapHost, ldapPort);
lc.bind(ldapVersion, loginDN, password.getBytes("UTF8"));
LDAPAttribute attribute = new LDAPAttribute(attrName, attrValue);
LDAPModification modification
= new LDAPModification(LDAPModification.ADD, attribute);
lc.modify(entryDN, modification);
lc.disconnect();
}

When the method is called

ldapManager.setAttribute("cn=TheUserName,cn=Users,dc=server,dc=domain,dc=com", "_custom", "TEST");

the following exception is thrown:

LDAPException: Undefined Attribute Type (17) Undefined Attribute Type
LDAPException: Server Message: Attribute _custom is not supported in schema.
LDAPException: Matched DN:
at com.novell.ldap.LDAPResponse.getResultException(Unknown Source)
at com.novell.ldap.LDAPResponse.chkResultCode(Unknown Source)
at com.novell.ldap.LDAPConnection.chkResultCode(Unknown Source)
at com.novell.ldap.LDAPConnection.modify(Unknown Source)
at com.novell.ldap.LDAPConnection.modify(Unknown Source)
at com.novell.ldap.LDAPConnection.modify(Unknown Source)
at lv.alise.eliepaja.ldap.LdapManager.setAttribute(LdapManager.java:156)
at lv.alise.eliepaja.ldap.LdapManager.main(LdapManager.java:178)
Exception in thread "main" Process exited with exit code 1.

How could I solve the issue?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 10 2006
Added on Jan 12 2006
1 comment
755 views