Erreur lors de la tentative de faire LDAP recherche dans active directory

Je suis en train de rechercher un utilisateur sur un local active directory à l'aide de java.

Lorsque j'essaie d'exécuter le code, j'obtiens l'erreur suivante:

Erreur:

De recherche a échoué: javax.de nommage.NamingException: [code d'erreur LDAP: 1 -
000004DC: Lda pErr: DSID-0C0906DC, commentaire: pour effectuer cette
opération réussie bi nd doit être effectuée sur la connexion.,
données 0, v1db1 ], le reste du nom: 'CN= John Doe, OU=Comptes

Quelqu'un pourrait-il me dire ce que je fais mal?

Mon code:

import java.util.Hashtable;    
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.naming.ldap.LdapContext;

/**
 * Demonstrates how to look up an object.
 * 
 * usage: java Lookup
 */
class Lookup {
    public static void main(String[] args) {

        //Set up the environment for creating the initial context
        Hashtable env = new Hashtable(11);
        env.put(Context.INITIAL_CONTEXT_FACTORY,
                "com.sun.jndi.ldap.LdapCtxFactory");
        env.put(Context.PROVIDER_URL,
                "ldap://localhost:389/DC=PORTAL-UAT,DC=COMPANY,DC=COM");

        try {
            //Create the initial context
            Context ctx = new InitialContext(env);

            //Perform lookup and cast to target type
            LdapContext b = (LdapContext) ctx
                    .lookup("CN=John Doe,OU=Accounts");

            System.out.println(b);

            //Close the context
            ctx.close();
        } catch (NamingException e) {
            System.out.println("Lookup failed: " + e);
        }
    }
}
InformationsquelleAutor Andreas | 2012-03-08