File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JNDI ? is it necessary

 
Monarch Bhojani
Ranch Hand
Posts: 46
  • 0
  • 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
Thanks
Monarch
 
Valentin Tanase
Ranch Hand
Posts: 704
  • 0
  • 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:

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 agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic