java - Unable to store information as attributes in LDAP using JNDI -
i'm trying bind java object set of attributes based on tutorial given here
//in main() method of program hashtable env = new hashtable(); env.put(context.initial_context_factory, "com.sun.jndi.ldap.ldapctxfactory"); env.put(context.provider_url, "ldap://localhost:10389/o=csrepository"); env.put(context.object_factories, "sample.userfactory"); // create initial context dircontext ctx = new initialdircontext(env); user usr = new user("goro"); ctx.bind("cn=kill bill, ou=employees", null, usr.getattributes(""));
i have user class follows,
public class user implements dircontext { string employer; attributes myattrs; public user(string employer){ this.employer = employer; myattrs = new basicattributes(true); attribute oc = new basicattribute("objectclass"); oc.add("extensibleobject"); oc.add("top"); myattrs.put(oc); myattrs.put("em", employer); } public attributes getattributes(string name) throws namingexception { if (!name.equals("")) { throw new namenotfoundexception(); } return (attributes) myattrs.clone(); } //other methods }
when trying bind get,
javax.naming.directory.nosuchattributeexception: [ldap: error code 16 - no_such_attribute: failed messagetype : add_request message id : 2 add request : entry dn[n]: cn=kill bill, ou=employees,o=csrepository objectclass: extensibleobject objectclass: top cn: kill bill em: goro managedsaitimpl control type oid : '2.16.840.1.113730.3.4.2' criticality : 'false' ' : err_04269 attribute_type oid em not exist!]; remaining name 'cn=kill bill, ou=employees'
why complain oid em not exist.
because doesn't. using extensibleobject
entitles add existing attribute object. doesn't entitle invent new attributes.
Comments
Post a Comment