This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma 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 Java Interview Guide this week in the Jobs Discussion 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: 42965
The Java API for using LDAP is called JNDI; its home page might be a good starting point for further research.
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
I agree. Here's the link:
subject: LDAP java question
It's not a secret anymore!