我们正在尝试使用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>
我得到:ActiveDirectoryLdapAuthenticationProvider handleBindException Active Directory身份验证失败:提供的密码无效错误 .
我的理解是,这是因为LDAP绑定失败,因为它正在寻找userDN /凭证 . 我们如何在配置文件中指定此信息?
在使用 ActiveDirectoryLdapAuthenticationProvider
之前,我使用了 <ldap-authentication-provider>
和 DefaultSpringSecurityContextSource
. 我可以在配置 DefaultSpringSecurityContextSource
bean时指定userDN /密码 . 有人能告诉我如何在使用 ActiveDirectoryLdapAuthenticationProvider
进行配置时指定userDn和密码吗?
1 回答
看起来你可能对
ActiveDirectoryLdapAuthenticationProvider
和how to configure it有点困惑 . 它使用user@domain.com
形式的类似电子邮件的名称进行绑定,其中domain.com
是您使用标准LDAP DN的参数 . 这特定于Active Directory,而不是标准LDAP的一部分 . 您可能还想查看该类的the source和Javadoc .如果您已经有一个标准的LDAP身份验证配置与您的设置一起使用,那么's not clear why you would want to change. You'可能更好地坚持您所拥有的,因为它不会与
ActiveDirectoryLdapAuthenticationProvider
直接兼容 .