0

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();
2
  • Why from Java? You can do it administratively. You only have to do it once. No point writing code when you don't need to. Commented Jun 8, 2017 at 11:40
  • Its not up to me to decide. It's a given task. Commented Jun 8, 2017 at 11:48

1 Answer 1

1

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();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.