This is my method for getting context
private DirContext getContext() throws NamingException {
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
properties.put(Context.PROVIDER_URL, "ldap://localhost:389");
retu new InitialDirContext(properties);
}
its giving context, I am trying to create object for String name = "employeeNumber=101, dc=example, dc=com"; Following is the method for creating Object
private void createLDAPObject(DirContext context, String name) throws NamingException {
Attributes attributes = new BasicAttributes();
Attribute attribute = new BasicAttribute("objectClass");
attribute.add("inetOrgPerson");
attributes.put(attribute);
Attribute sn = new BasicAttribute("sn");
sn.add("Steve");
attributes.put(sn);
Attribute cn = new BasicAttribute("cn");
cn.add("Jobs");
attributes.put(cn);
attributes.put("telephoneNumber", "12345");
context.createSubcontext(name, attributes);
}
its working fine for Apache Dirctory Studios, if I use String name= "employeeNumber=101, ou=system"; uri = "ldap://localhost:10389"; I am replacing it with String name="employeeNumber=101, dc=example, dc=com"; uri = "ldap://localhost:389"; but not working with OpenLDAP
