我正在尝试通过java访问AD。当我运行代码时,我收到以下错误:
线程“main”中的异常java.lang.RuntimeException: javax.naming.AuthenticationException:[LDAP:错误代码49 - 8009030C: LdapErr:DSID-0C0903C5,注释:AcceptSecurityContext错误,数据 2030,v23f0] at com.ceiwc.TestAD.main(TestAD.java:40)引起: javax.naming.AuthenticationException:[LDAP:错误代码49 - 8009030C: LdapErr:DSID-0C0903C5,注释:AcceptSecurityContext错误,数据 2030,v23f0] at com.sun.jndi.ldap.LdapCtx.mapErrorCode(Unknown 来源)com.sun.jndi.ldap.LdapCtx.processReturnCode(未知) 来源)com.sun.jndi.ldap.LdapCtx.processReturnCode(未知) 来源)com.sun.jndi.ldap.LdapCtx.connect(未知来源)at com.sun.jndi.ldap.LdapCtx。(未知来源)at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(未知来源)at at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(未知来源)at at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(未知来源) at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(Unknown Source) 在javax.naming.spi.NamingManager.getInitialContext(未知来源) 在javax.naming.InitialContext.getDefaultInitCtx(未知来源)at javax.naming.InitialContext.init(未知来源)at javax.naming.InitialContext。(未知来源)at javax.naming.directory.InitialDirContext。(未知来源)at com.ceiwc.TestAD.main(TestAD.java:38)
我收到与this post here完全相同的错误。 有人熟悉这个错误吗?
这是我的代码:
String ldapAdServer = "ldap://ivdstest.testserver.com";
String userName = "lds";
String password = "Testing.";
Hashtable<String, Object> env = new Hashtable<String, Object>();
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, userName);
env.put(Context.SECURITY_CREDENTIALS, password);
env.put(Context.PROVIDER_URL, ldapAdServer);
DirContext ctx;
try {
ctx = new InitialDirContext(env);
} catch (NamingException e) {
throw new RuntimeException(e);
}
非常感谢任何帮助!