0

我正在尝试通过 java 访问 AD。当我运行代码时,我收到以下错误:

线程“主”java.lang.RuntimeException 中的异常:javax.naming.AuthenticationException:[LDAP:错误代码 49 - 8009030C:LdapErr:DSID-0C0903C5,注释:AcceptSecurityContext 错误,数据 2030,v23f0] 在 com.ceiwc.TestAD。 main(TestAD.java:40) 引起:javax.naming.AuthenticationException:[LDAP:错误代码 49 - 8009030C:LdapErr:DSID-0C0903C5,注释:AcceptSecurityContext 错误,数据 2030,v23f0] 在 com.sun.jndi.ldap .LdapCtx.mapErrorCode(Unknown Source) at com.sun.jndi.ldap.LdapCtx.processReturnCode(Unknown Source) at com.sun.jndi.ldap.LdapCtx.processReturnCode(Unknown Source) at com.sun.jndi.ldap.LdapCtx .connect(Unknown Source) at com.sun.jndi.ldap.LdapCtx.(Unknown Source) at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(Unknown Source) at com.sun.jndi.ldap.LdapCtxFactory。getUsingURLs(Unknown Source) at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(Unknown Source) at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(Unknown Source) at javax.naming.spi.NamingManager.getInitialContext(Unknown Source ) 在 javax.naming.InitialContext.getDefaultInitCtx(Unknown Source) 在 javax.naming.InitialContext.init(Unknown Source) 在 javax.naming.InitialContext.(Unknown Source) 在 javax.naming.directory.InitialDirContext.(Unknown Source) 在com.ceiwc.TestAD.main(TestAD.java:38)InitialContext.init(Unknown Source) at javax.naming.InitialContext.(Unknown Source) at javax.naming.directory.InitialDirContext.(Unknown Source) at com.ceiwc.TestAD.main(TestAD.java:38)InitialContext.init(Unknown Source) at javax.naming.InitialContext.(Unknown Source) at javax.naming.directory.InitialDirContext.(Unknown Source) at com.ceiwc.TestAD.main(TestAD.java:38)

我在这里得到与这篇文章相同的错误。有人熟悉这个错误吗?

这是我的代码:

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);
    }

任何帮助是极大的赞赏!

4

0 回答 0