This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Security and the fly likes LDAP java question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Security
Bookmark "LDAP java question" Watch "LDAP java question" New topic

LDAP java question

Tim Cerillo
Ranch Hand

Joined: Sep 10, 2002
Posts: 44
I am trying to code something that will identify duplicate user ids
from two different directories. What is the best approach in Java? Do
you know any article or online books that would get me up to speed
with LDAP programming with Java? Thanks a lot.
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 41034
The Java API for using LDAP is called JNDI; its home page might be a good starting point for further research.

Ping & DNS - my free Android networking tools app
Tim Cerillo
Ranch Hand

Joined: Sep 10, 2002
Posts: 44
Thanks Ulf. I was able to make a successful connection to LDAP via JNDI. I'm a java greenhorn, how can I compare two directories for duplicates say in lastname attribute. I already have the connection to both the directories. Can someone share some codes on how to search thru one attribute and compare with the same attribute on the second directory? Thanks in advance.
Stefan Zoerner
Ranch Hand

Joined: Nov 29, 2001
Posts: 121

how many entries do your directories have? One option would be to fetch all users from directory A, and for each entry make a search for the attributes you interested in on directory B. Check out the JNDI Tutorial at Sun for code examples on how to perform search ops with JNDI. Note that the surname is normally not capable to identify a user, because it tends not to be unique (some serial number would do better).

If your directories contain many entries, this algorithm would be rather slow. It is probably better to export the entries into something else instead of using 2 connections to different directories ... But this depends on how often the task should be performed.

Hope that helped, Stefan

Stefan Zoerner
Author of German LDAP-Book
Committer at Apache Directory Project
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: LDAP java question
Similar Threads
hi What is Java Naming and Directory Interface?
Welcome Clayton (and everyone else)!
Need an example on LDAP with EJB Stateless Session beans
Authentication mechanism and code procedure from web app to an LDAP server
Saving password field in LDAP Server