【发布时间】:2019-03-22 20:28:41
【问题描述】:
我已经在 Windows 2012 Server 中设置了 AD DS 和 AD LDS。
要求是使用 Java 查询到 LDAP。
我试过这个:
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://55.22.44.22:53358");
env.put(Context.SECURITY_AUTHENTICATION, "simple");
"CN=ecode,CN=Users,DC=ecode,DC=com");
env.put(Context.SECURITY_PRINCIPAL, "ecode@ecode.com");
env.put(Context.SECURITY_CREDENTIALS, "ddadadad");
DirContext context = new InitialDirContext(env);
我收到以下错误
线程“main”javax.naming.AuthenticationException 中的异常:[LDAP:错误代码 49 - 8009030C:LdapErr:DSID-0C09042F,注释:AcceptSecurityContext 错误,数据 2030,v2580�]
在 com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3154)
在 com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:3100)
在 com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2886)
在 com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2800) 在 com.sun.jndi.ldap.LdapCtx.(LdapCtx.java:319) 在 com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(LdapCtxFactory.java:192) 在 com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(LdapCtxFactory.java:210) 在 com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(LdapCtxFactory.java:153) 在 com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(LdapCtxFactory.java:83)
我知道代码 49 是 LDAP_INVALID_CREDENTIALS。我不确定要传入什么
SECURITY_AUTHENTICATION参数。
我已尝试在参数中以SECURITY_AUTHENTICATION 的形式关注:
CN=ecode,CN=Users,DC=ecode,DC=com
ecode@ecode.com
当我尝试时在 Powershell 中
dsquery user -name ecode
我得到这个输出
CN=ecode,CN=Users,DC=ecode,DC=com
【问题讨论】:
标签: active-directory ldap windows-server-2012