Spring ActiveDirectoryLdapAuthenticationProvider handleBindException - 提供的密码无效错误

ign*_*tan 2 passwords active-directory spring-security spring-ldap

我们正在尝试使用Spring安全性来对我们的企业LDAP进行身份验证.我正在使用ActiveDirectoryLdapAuthenticationProvider.下面是Spring配置文件的片段:

<security:authentication-manager erase-credentials="true">
    <security:authentication-provider  ref="ldapActiveDirectoryAuthProvider"/>
</security:authentication-manager>

<bean id="ldapActiveDirectoryAuthProvider" class="org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAuthenticationProvider">
<constructor-arg value="DC=xxx,DC=ds,DC=yyy,DC=com" />  
<constructor-arg value="ldap://xxx.ds.yyy.com:389" />
<property name="convertSubErrorCodesToExceptions" value="true"/>
</bean>
Run Code Online (Sandbox Code Playgroud)

我得到:ActiveDirectoryLdapAuthenticationProvider handleBindException Active Directory身份验证失败:提供的密码无效错误.

我的理解是,这是因为LDAP绑定失败,因为它正在寻找userDN /凭证.我们如何在配置文件中指定此信息?

在使用之前ActiveDirectoryLdapAuthenticationProvider,我使用<ldap-authentication-provider>和使用了这个DefaultSpringSecurityContextSource.我可以在配置DefaultSpringSecurityContextSourcebean 时指定userDN /密码.在配置使用时,有人能告诉我如何指定userDn和密码ActiveDirectoryLdapAuthenticationProvider吗?

Sha*_*eep 7

看起来你可能会对它的配置ActiveDirectoryLdapAuthenticationProvider配置方式感到有些困惑.它结合的形式使用电子邮件般的名字user@domain.com,其中domain.com的参数,你的第一个构造函数所提供.它不使用标准LDAP DN.这特定于Active Directory,而不是标准LDAP的一部分.您可能还想查看该类的源代码和Javadoc.

如果您已经有一个标准的LDAP身份验证配置与您的设置一起使用,那么您不清楚为什么要更改.你可能更好地坚持你所拥有的,因为它不会直接兼容ActiveDirectoryLdapAuthenticationProvider.