I am trying to connect to AD using Anonymous binding
and do some operations like search a user DN using CN, find mail id etc ....
Here is the code:
public class TestADAnanymousConnection {
public static void main(String[] args) throws NamingException {
Hashtable<String, Object> env = new Hashtable<String, Object>();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL,
"ldap://localhost:389/dc=myad,dc=com");
env.put(Context.SECURITY_AUTHENTICATION, "none");
DirContext ctx;
ctx = new InitialDirContext(env);
System.out.println(ctx.lookup("cn=Administrator"));
}
}
It shows error message as below:
Exception in thread "main" javax.naming.NamingException: [LDAP: error code 1 - 000004DC: LdapErr: DSID-0C0906E8, comment: **In order to perform this operation a successful bind must be completed on the connection**., data 0, v1db1 remaining name 'cn=Administrator'
at line System.out.println(ctx.lookup("cn=Administrator"));
Can somebody please let me know whether I missed anything in the code?
Thanks.