3
我是Spring的新手,所以这个问题可能看起来很明显。如何在Spring安全中进行LDAP身份验证和数据库授权?
我试图实现Spring安全性,我的要求是验证对LDAP服务器的用户名/密码,一旦用户通过身份验证,我需要从关系数据库检索用户角色。
是否有可能在Spring安全中做到这一点?
我是Spring的新手,所以这个问题可能看起来很明显。如何在Spring安全中进行LDAP身份验证和数据库授权?
我试图实现Spring安全性,我的要求是验证对LDAP服务器的用户名/密码,一旦用户通过身份验证,我需要从关系数据库检索用户角色。
是否有可能在Spring安全中做到这一点?
是的。
内置ldap认证管理器将用户的认证和授权分为两部分 您可以像下面那样配置基于LDAP的认证管理器。
<bean id="authenticationManager" class="org.acegisecurity.providers.ProviderManager">
<property name="providers">
<list>
<ref local="ldapAuthenticationProvider"/>
</list>
</property>
</bean>
身份验证提供程序是这样配置的。
<bean id="ldapAuthenticationProvider" class="org.acegisecurity.providers.ldap.LdapAuthenticationProvider">
<constructor-arg><ref local="authenticator"/></constructor-arg>
<constructor-arg><ref local="populator"/></constructor-arg>
<property name="userCache"><ref local="userCache"/></property>
</bean>
我不知道是否有一个内置的populator可以做你想做的,但是如果需要你可以开发你自己的。
您可以使用UserDetailsServiceLdapAuthoritiesPopulator委托给标准的UserDetailsService。这将完全符合Veera的需求。 – 2009-05-28 10:13:41