Authenticating via LDAP and JNDI

J

John English

Can anyone tell me how to do password authentication against an LDAP
server in Java? Here's how I do it in PHP...

$ldap = ldap_connect("ldap.bton.ac.uk");
if (ldap_bind($ldap)) {
$srch = ldap_search($ldap,"ou=people,dc=brighton,dc=ac,dc=uk",
"uid=$user",array("uid"));
if ($srch) {
$dn = ldap_get_dn($ldap,ldap_first_entry($ldap,$srch));
if ($dn) {
if (ldap_unbind($ldap)) {
$ldap = ldap_connect("ldap.bton.ac.uk");
if (@ldap_bind($ldap,$dn,$pass)) {
return strtoupper($user);
}
}
}
}
}

I'm finding it a bit hard to figure out how to connect, bind, search,
get DNs, and other such simple things...

Any pointers much appreciated!

-----------------------------------------------------------------
John English | mailto:[email protected]
Senior Lecturer | http://www.it.bton.ac.uk/staff/je
School of Computing & MIS | ** NON-PROFIT CD FOR CS STUDENTS **
University of Brighton | -- see http://burks.bton.ac.uk
-----------------------------------------------------------------
 
R

Rene

John English said:
Can anyone tell me how to do password authentication against an LDAP
server in Java? Here's how I do it in PHP...


I'm finding it a bit hard to figure out how to connect, bind, search,
get DNs, and other such simple things...

Any pointers much appreciated!

Here you'll find explanations and code samples:

http://java.sun.com/products/jndi/tutorial/

HTH.

CU

Rene
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top