我正在尝试对 JSF 网站使用 Spring Security 3.0.2 LDAP 身份验证。当我在 applicationContext-security.xml 中使用以下配置时,我得到了这个异常 - org.springframework.beans.factory.BeanCreationException: Error Creating bean with name 'org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices#0': bean初始化失败;嵌套异常是 org.springframework.context.ApplicationContextException: No UserDetailsService 注册。
<authentication-manager>
<ldap-authentication-provider
user-search-filter="(uid={0})" user-search-base="ou=users,ou=system"
group-search-base="ou=groups,ou=system">
</ldap-authentication-provider>
</authentication-manager>
<ldap-server id="ldapServer" url="ldap://localhost:10389"
root="" />
我刚刚进行了实验,发现添加以下内容可以使事情正常进行。
<ldap-user-service server-ref="ldapServer" user-search-filter="(uid={0})" />
但我在Spring LDAP 文档中找不到对此的引用。如果我不添加这个,为什么会出现上述异常?我对这种解决方法不满意,因为我需要在两个地方编写 user-search-filter 属性。
PS:我已经检查了Spring Security LDAP-No UserDetailsService 注册。那里的例外是不同的,我猜 Spring Security 版本也不同。