• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

First node in LDAP and JNDI problem

 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic