Reputation: 89
I have to create a custom Object Class in LDAP server from java JNDI. The object class should have 3 fields with values: Name, OID, Description. So far I have managed to only define the environment.
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
properties.put(Context.PROVIDER_URL, ldapUrl);
properties.put(Context.REFERRAL, "ignore");
properties.put(Context.SECURITY_PRINCIPAL, dirManagerUser);
properties.put(Context.SECURITY_CREDENTIALS, password);
DirContext ctx = new InitialDirContext(properties);
//NEW CUSTOM OBJECT CREATION SHOULD GO HERE
ctx.close();
Upvotes: 0
Views: 730
Reputation: 89
I found a solution:
BasicAttribute attribute = new BasicAttribute("objectClasses");
attribute.add(parameters);
attributes.put(attribute);
context.modifyAttributes("cn=schema",DirContext.ADD_ATTRIBUTE, attributes);
context.close();
Upvotes: 1