我无法使用Spring安全性验证用户,我收到了BadCredentailException。 我的弹簧安全配置是:
<bean id="contextSource"
class="org.springframework.security.ldap.DefaultSpringSecurityContextSource">
<constructor-arg value="ldaps://ldaps.prod.sam.com:636"/>
<property name="userDn" value="CN=!testUser1,OU=Service Accounts,OU=User Accounts,DC=prod,DC=sam,DC=com"/>
<property name="password" value="!!testPass1!!"/>
<property name="referral" value="follow"/>
</bean>
<bean class="org.springframework.security.ldap.search.FilterBasedLdapUserSearch" id="ldapSearchBean">
<constructor-arg value="OU=User Accounts,DC=prod,DC=sam,DC=com"/>
<constructor-arg value="(sAMAccountName={0})"/>
<constructor-arg ref="contextSource"/>
<property name="searchSubtree" value="true"/>
</bean>
<bean class="org.springframework.security.ldap.authentication.BindAuthenticator" id="ldapBindAuthenticator">
<constructor-arg ref="contextSource"/>
<property name="userSearch" ref="ldapSearchBean"/>
</bean>
<bean class="org.springframework.security.ldap.userdetails.DefaultLdapAuthoritiesPopulator" id="ldapAuthoritiesPopulator">
<constructor-arg value="ou=Groups"/>
<constructor-arg ref="contextSource"/>
<property name="groupRoleAttribute" value="memberOf"/>
</bean>
<bean class="org.springframework.security.ldap.userdetails.InetOrgPersonContextMapper" id="ldapUserDetailsContextMapper">
</bean>
<bean id="ldapAuthProvider" class="org.springframework.security.ldap.authentication.LdapAuthenticationProvider">
<constructor-arg ref="ldapBindAuthenticator"/>
<constructor-arg ref="ldapAuthoritiesPopulator"/>
<property name="useAuthenticationRequestCredentials" value="false"/>
<property name="userDetailsContextMapper" ref="ldapUserDetailsContextMapper" />
</bean>
<security:authentication-manager alias="authenticationManager" >
<security:authentication-provider ref="ldapAuthProvider"/>
</security:authentication-manager>
例外是:
org.springframework.security.authentication.BadCredentialsException: Bad credentials
at org.springframework.security.ldap.authentication.BindAuthenticator.authenticate(BindAuthenticator.java:95)
at org.springframework.security.ldap.authentication.LdapAuthenticationProvider.doAuthentication(LdapAuthenticationProvider.java:178)
at org.springframework.security.ldap.authentication.AbstractLdapAuthenticationProvider.authenticate(AbstractLdapAuthenticationProvider.java:61)
at org.springframework.security.authentication.ProviderManager.authenticate(ProviderManager.java:156)
当我逐步验证ldap用户成功时,测试用户验证失败了。我认为问题在于基本路径。谁能说出我错过了什么?