Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Authenticating via LDAP and JNDI

Reply
Thread Tools

Authenticating via LDAP and JNDI

 
 
John English
Guest
Posts: n/a
 
      02-25-2005
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 | (E-Mail Removed)
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
-----------------------------------------------------------------

 
Reply With Quote
 
 
 
 
Rene
Guest
Posts: n/a
 
      02-25-2005
John English <(E-Mail Removed)> wrote:
> 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

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Authenticating LDAP connection with current windows user's credentials? bugnthecode Java 5 02-08-2007 05:44 AM
why use ENC JNDI (java:comp/env) instead of JNDI name ? Mick Java 2 02-23-2005 12:50 PM
Help -- Authenticating user against LDAP using ASP DejaUser ASP General 0 12-23-2004 07:17 PM
Need Help with Hibernate - "Not binding factory to JNDI, no JNDI name configured" Mike S Java 0 09-16-2004 09:58 PM
How do you figure out the LDAP://? ("Error authenticating. Error authenticating user. The specified domain either does not exist or could not be contacted") mrwoopey ASP .Net 3 06-30-2003 10:11 PM



Advertisments