使用Apache LDAP AIP连接到MS LDAP时的错误



im使用apache ldap api连接到MS Active Directory,但我收到以下错误:

调试#c.s.m.c.r.c.c.apacheldapclient ##匿名#http-bio-8080-8080-exec-6 ###连接到ldap org.apache.directory.api.papi.ldap.modap.model.exception.ldapion.dapapauthententicuticeexcepti,意外错误on:80090308:ldaperr:dsid-0c0903d9,评论:AcceptSecurityContext错误,数据52E,V2580^@

在这种情况下,我刚刚在ldapConnectionConfig.name和ldapConnect类的绑定方法中提供了LDAP用户名和密码。

根据一些研究和测试,我可以看到,当我提供用户的完整DN(杰出名称)时,连接和绑定正常。

所以我的问题是:是否有一种方法可以连接并使用Apache LDAP API绑定到MS AD,只是提供用户名和密码(不是完整的DN)?

以下是失败的源代码的摘录:

LdapConnection conn = new LdapNetworkConnection();
connParams.setLdapHost(LDAP_HOST);
connParams.setLdapPort(389);
connParams.setName(test_user);
connParams.setCredentials(TEST_USER_PASSWORD);
LdapConnection connection = new LdapConnection(connParams);
connection.bind(test_user, TEST_USER_PASSWORD);

,这是很好的工作:

LdapConnection conn = new LdapNetworkConnection();
connParams.setLdapHost(LDAP_HOST);
connParams.setLdapPort(389);
connParams.setName(CN=test_user,DC=Example,DC=com);
connParams.setCredentials(TEST_USER_PASSWORD);
LdapConnection connection = new LdapConnection(connParams);
connection.bind(CN=test_user,DC=Example,DC=com, TEST_USER_PASSWORD);

毕竟,您必须使用特殊名称进行绑定-LDAP毕竟不知道Active Directory。当然,您可以首先使用服务帐户来检索samaccountname的DN。

最新更新