Authenticating via LDAP and JNDI

Discussion in 'Java' started by John English, Feb 25, 2005.

  1. John English

    John English Guest

    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:
    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
    -----------------------------------------------------------------
     
    John English, Feb 25, 2005
    #1
    1. Advertising

  2. John English

    Rene Guest

    John English <> 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
     
    Rene, Feb 25, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mrwoopey
    Replies:
    3
    Views:
    9,645
    mrwoopey
    Jun 30, 2003
  2. Mike S
    Replies:
    0
    Views:
    23,108
    Mike S
    Sep 16, 2004
  3. Mick
    Replies:
    2
    Views:
    9,669
    Marcin Grunwald
    Feb 23, 2005
  4. bugnthecode
    Replies:
    5
    Views:
    4,188
    Brandon McCombs
    Feb 8, 2007
  5. DejaUser
    Replies:
    0
    Views:
    188
    DejaUser
    Dec 23, 2004
Loading...

Share This Page