开发者

Spring LDAP exception - No UserDetailsService registered

I am trying to use Spring Security 3.0.2 LDAP authentication for a JSF website. When I use the below configuration in applicationContext-security.xml I get this exception - org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices#0': Initialization of bean failed; nested except开发者_StackOverflow社区ion is org.springframework.context.ApplicationContextException: No UserDetailsService registered.

<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="" />

I just experimented and found that adding the below makes things work.

<ldap-user-service server-ref="ldapServer" user-search-filter="(uid={0})" />

But I could not find references to this in the Spring LDAP documentation. Why do I get the above exception if I do not add this? I am not happy with this workaround as I need to write user-search-filter attribute at two places.

PS: I have checked Spring Security LDAP - No UserDetailsService registered. There the exception is different and I guess the Spring Security version is different as well.


I suspect you have <remember-me/> set later in the security context. As per documentation: http://static.springsource.org/spring-security/site/docs/3.1.x/reference/springsecurity-single.html#remember-me

If you are using an authentication provider which doesn't use a UserDetailsService (for example, the LDAP provider) then it won't work unless you also have a UserDetailsService bean in your application context.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜