• Post Reply Bookmark Topic Watch Topic
  • New Topic

First node in LDAP and JNDI problem  RSS feed

 
Ricardo Polero
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, in my code
....
Hashtable ht = new Hashtable();
ht.put(Context.SECURITY_PRINCIPAL, "cn=Directory Manager,dc=x,dc=com");
ht.put(Context.SECURITY_PRINCIPAL, "cn=Directory Manager");
ht.put(Context.SECURITY_CREDENTIALS, "password");
ht.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
ht.put(Context.PROVIDER_URL, "ldap://localhost:389");
InitialDirContext initcntx = new InitialDirContext(ht);
// get the namespace
String namespace = initcntx.getNameInNamespace();
BasicAttributes attrs = new BasicAttributes();
// the new is sub-class of the person witch is subclass of top. Store the hierarchy in objectclass attb
Attribute classes = new BasicAttribute("objectclass");
classes.add("top");
classes.add("person");
classes.add("organizationalperson");
// add attclasses to to the attrib set
attrs.put(classes);
String shost = "ldap://localhost/cn=Ricardo Baraldi," + "o=x,dc=xp,dc=com";
//add the new entry to direct server
initcntx.createSubcontext(shost, attrs);
I always got an NamingException. The tree is empty because is the first node. How can i create the firts time node (root)?
Best Regards
Ricardo
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ht.put(Context.SECURITY_PRINCIPAL, "cn=Directory Manager,dc=x,dc=com");
ht.put(Context.SECURITY_PRINCIPAL, "cn=Directory Manager");
I assume, you realize that the second statement will replacethe first statement.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!