L'utilisateur LDAP authentification par mot de passe en utilisant 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);
    }
}

Je voudrais demander quand j'ai mis le MGR_DN = "cn=John,ou=Users,o=IT,dc=QuizPortal" à MGR_DN = "uid=103,ou=Users,o=IT,dc=QuizPortal". Fondamentalement changer de cn, uid, je rencontre une erreur

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

Je suis authentifié quand est spécifié comme cn=John mais pas uid=103. Ne suis-je pas autorisé à spécifier par uid?

OriginalL'auteur Nivek | 2010-08-11