• Post Reply Bookmark Topic Watch Topic
  • New Topic

JNDI ? is it necessary  RSS feed

Monarch Bhojani
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all
I am developing an application related to chat that has to use LDAP as the directory service. I have started refering JNDI tutorial of SUN. I wanted to ask that it is necessary to read JNDI to proceed for LDAP.
What would be best help i could get to understand LDAP.
One more thing how to create directory using LDAP
All needs to be in JAVA
Valentin Tanase
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you use Sun API you�ll need a high level understanding of the JNDI concepts, since in a nutshell LDAP is a more specialized form of JNDI. So it uses the underlying JNDI service for resolving LDAP requests. However if you chose the Netscape Directory SDK (which was bought by Sun anyway) you might skip understanding (at least for now) the JNDI concepts. If you need more advanced knowledge you can try to integrate the Netscape Directory SDK with JNDI. You might like checking this link:


Below there is some code extras that help you understand how to connect to the LDAP database and create a new entry (remark that no JNDI knowledge is required).
LDAPConnection ldapConn = new LDAPConnection();

ldapConn.connect(3, "localhost", "1080",
"uid=$system$,ou=internalPeople,dc=acme,dc=com", "weblogic");
ldapConn.setOption(LDAPv2.SIZELIMIT, new Integer(0));
ldapConn.setOption(LDAPv2.REFERRALS, Boolean.TRUE);
ldapConn.setOption(LDAPv2.BATCHSIZE, new Integer(1000));
ldapConn.setOption(LDAPv2.TIMELIMIT, new Integer(15000));


String[] objectclasses = {"top", "groupofuniquenames"};
LDAPAttribute objectClass = new LDAPAttribute("objectclass",
LDAPAttribute cn = new LDAPAttribute("cn", "cn=WebAdmin,ou=roles,dc=acme,dc=com");

LDAPAttributeSet attrSet = new LDAPAttributeSet();


LDAPAttribute description = new LDAPAttribute("description",
"Role for web administrators");

String roleDn = LdapUtil.distinguishedRoleName(role.getRoleName());
LDAPEntry entry = new LDAPEntry(roleDn, attrSet);

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!