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. Advertisements

  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. Advertisements

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,968
    mrwoopey
    Jun 30, 2003
  2. Ray Dees

    JNDI LDAP problem in JRE 1.4

    Ray Dees, Sep 5, 2003, in forum: Java
    Replies:
    0
    Views:
    849
    Ray Dees
    Sep 5, 2003
  3. Mark
    Replies:
    0
    Views:
    3,260
  4. Mike S
    Replies:
    0
    Views:
    23,444
    Mike S
    Sep 16, 2004
  5. Mick
    Replies:
    2
    Views:
    10,295
    Marcin Grunwald
    Feb 23, 2005
  6. Akaketwa
    Replies:
    1
    Views:
    6,365
    impaler
    Sep 22, 2006
  7. bugnthecode
    Replies:
    5
    Views:
    5,215
    Brandon McCombs
    Feb 8, 2007
  8. DejaUser
    Replies:
    0
    Views:
    282
    DejaUser
    Dec 23, 2004
Loading...