LDAP-Benutzer-Passwort-Authentifizierung mithilfe von JNDI

public static void main(String[] args)
{
    String INITCTX = "com.sun.jndi.ldap.LdapCtxFactory";
    String MY_HOST = "ldap://Localhost:1389";
    String MGR_DN = "cn=John,ou=Users,o=IT,dc=QuizPortal";
    String MGR_PW = "password";           

    //Identify service provider to use
    Hashtable env = new Hashtable();
    env.put(Context.INITIAL_CONTEXT_FACTORY, INITCTX);
    env.put(Context.PROVIDER_URL, MY_HOST);
    env.put(Context.SECURITY_AUTHENTICATION, "simple");
    env.put(Context.SECURITY_PRINCIPAL, MGR_DN);
    env.put(Context.SECURITY_CREDENTIALS, MGR_PW);

    try
    {
        //Create the initial directory context
        InitialDirContext initialContext = new InitialDirContext(env);

        System.out.println("Context Sucessfully Initialized");
    }
    catch(Exception e)
    {
        System.err.println(e);
    }
}

Ich würde gerne Fragen, wenn ich die MGR_DN = "cn=John,ou=Users,o=IT,dc=QuizPortal" zu MGR_DN = "uid=103,ou=Users,o=IT,dc=QuizPortal". Im Grunde Wechsel von cn uid, würde ich auf einen Fehler stoßen

javax.naming.AuthenticationException: [LDAP: error code 49 - Invalid Credentials]

Bin ich authentifiziert, wenn angegeben ist, wie cn=John aber nicht uid=103. Bin ich nicht angeben dürfen, durch die uid?

InformationsquelleAutor Nivek | 2010-08-11
Schreibe einen Kommentar