Results 1 to 3 of 3
  1. #1
    peiceonly is offline Member
    Join Date
    Mar 2007
    Posts
    41
    Rep Power
    0

    Question Configuring LDAP and JAVA

    How can I authenticate a user against LDAP in java ?
    Do sun has direct API for this ?

  2. #2
    goldhouse is offline Senior Member
    Join Date
    Mar 2007
    Posts
    134
    Rep Power
    0

    Default

    The following example shows how, by using a simple clear-text password, a client authenticates to an LDAP server.
    Java Code:
        // Set up the environment for creating the initial context
        Hashtable env = new Hashtable();
        env.put(Context.INITIAL_CONTEXT_FACTORY, 
            "com.sun.jndi.ldap.LdapCtxFactory");
        env.put(Context.PROVIDER_URL, "ldap://localhost:389/o=JNDITutorial");
    
        // Authenticate as S. User and password "mysecret"
        env.put(Context.SECURITY_AUTHENTICATION, "simple");
        env.put(Context.SECURITY_PRINCIPAL, "cn=S. User, ou=NewHires, o=JNDITutorial");
        env.put(Context.SECURITY_CREDENTIALS, "mysecret");
    
        // Create the initial context
        DirContext ctx = new InitialDirContext(env);
    
        // ... do something useful with ctx
    If it returns DirContext then there is no error else it will throws exception

  3. #3
    goldhouse is offline Senior Member
    Join Date
    Mar 2007
    Posts
    134
    Rep Power
    0

Similar Threads

  1. Configuring Jboss with Eclipse
    By javaplus in forum Advanced Java
    Replies: 3
    Last Post: 05-07-2009, 11:16 AM
  2. CompositeName with LDAP URL
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-10-2008, 10:43 AM
  3. Replies: 0
    Last Post: 07-30-2007, 11:13 PM
  4. Replies: 0
    Last Post: 04-26-2007, 10:15 AM
  5. Configuring J2EE Environment on Eclipse IDE
    By JavaForums in forum Eclipse
    Replies: 0
    Last Post: 04-26-2007, 10:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •