File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes JNDI  ? is it necessary Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "JNDI  ? is it necessary" Watch "JNDI  ? is it necessary" New topic
Author

JNDI ? is it necessary

Monarch Bhojani
Ranch Hand

Joined: Feb 27, 2005
Posts: 46
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
Thanks
Monarch
Valentin Tanase
Ranch Hand

Joined: Feb 17, 2005
Posts: 704
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:

http://docs.sun.com/source/816-6402-10/api.htm

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).
[code]
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",
objectclasses);
LDAPAttribute cn = new LDAPAttribute("cn", "cn=WebAdmin,ou=roles,dc=acme,dc=com");

LDAPAttributeSet attrSet = new LDAPAttributeSet();

attrSet.add(objectClass);
attrSet.add(cn);

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

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

ldapConn.add(entry);
ldapConn.disconnect();
[/qode]


I think, therefore I exist -- Rene Descartes
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JNDI ? is it necessary