This is the following program which works fine for some ADS servers(deployed on 2008 server) but fails to connect to the AD server deployed on AD server(deployed on 2012 server). I am getting the following exception wgile connecting
[LDAP: error code 49 - 8009030C: LdapErr: DSID-0C0903C5, comment: AcceptSecurityContext error, data 2030, v23f0]
the same exception is occured while using JXplorer also.
Can any one help me on this.
import java.util.Hashtable;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.directory.DirContext;
import javax.naming.directory.InitialDirContext;
import javax.naming.directory.SearchControls;
import javax.naming.directory.SearchResult;
public class TestLdap {
public static void main(String[] args) {
String base = "";
String filter = "(objectclass=*)";
Hashtable<String,String> env = new Hashtable<String,String>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://example.com:389/dc=example,dc=com");
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, "test@example.com");
env.put(Context.SECURITY_CREDENTIALS, "secret");
try {
DirContext dc = new InitialDirContext(env);
SearchControls sc = new SearchControls();
sc.setSearchScope(SearchControls.OBJECT_SCOPE);
NamingEnumeration ne = null;
while (ne.hasMore()) {
SearchResult sr = (SearchResult) ne.next();
System.out.println(sr.toString()+"\n");
}
dc.close();
} catch (NamingException nex) {
System.err.println("Error: " + nex.getMessage());
}
}
}