Spring security Spring Security Java配置多组搜索库

Spring security Spring Security Java配置多组搜索库,spring-security,spring-security-ldap,Spring Security,Spring Security Ldap,我将SpringSecurity3.2.5与Java配置和LDAP身份验证/授权一起使用 我们需要在LDAP中的两个独立树中搜索组 ou=组 及 ou=组,ou=网络应用程序,ou=应用程序 我已经搜索过了,但是找不到关于这个主题的任何信息 这是我当前的代码,运行良好: @Autowired public void configureGlobal(UserDetailsContextMapper userDetailsContextMapper, LdapContextSource contex

我将SpringSecurity3.2.5与Java配置和LDAP身份验证/授权一起使用

我们需要在LDAP中的两个独立树中搜索组

ou=组

ou=组,ou=网络应用程序,ou=应用程序

我已经搜索过了,但是找不到关于这个主题的任何信息

这是我当前的代码,运行良好:

@Autowired
public void configureGlobal(UserDetailsContextMapper userDetailsContextMapper, LdapContextSource contextSource, AuthenticationManagerBuilder builder) throws Exception {


    builder
    .ldapAuthentication()
        .userDetailsContextMapper(userDetailsContextMapper)
        .contextSource(contextSource)
        .userSearchFilter("cn={0}")
        .userSearchBase("ou=Users")
        .groupSearchBase("ou=groups");


}
我想这样做:

    builder
    .ldapAuthentication()
        .userDetailsContextMapper(userDetailsContextMapper)
        .contextSource(contextSource)
        .userSearchFilter("cn={0}")
        .userSearchBase("ou=Users")
        .groupSearchBase("ou=groups")
        .groupSearchBase("ou=Groups,ou=webapps,ou=Applications");
这是可以理解的,不起作用


有人知道从哪里开始吗?

我的解决方案是创建一个
org.springframework.security.ldap.userdetails.ldapaauthoritiespoplator
的实现,它可以调用
ldapaauthoritiespoplator
的多个实例。然后为我要查询的每个“groupSearchBase”创建一个
ldaAuthoritiesPopulator

@Autowired
public void configureGlobal(UserDetailsContextMapper UserDetailsContextMapper、LdapContextSource contextSource、AuthenticationManagerBuilder)引发异常{
multipledAPauthoritiesPopulator multipledAPauthoritiesPopulator=新的multipledAPauthoritiesPopulator(
新的DefaultLdapAuthoritiesPopulator(contextSource,“ou=Groups,ou=webapps,ou=Applications”),
新的DefaultLdapAuthoritiesPopulator(contextSource,“ou=groups”);
建设者
.lda身份验证()
.ldapAuthoritiesPopulator(MultipledAPauthoritiesPopulator)
.userDetailsContextMapper(userDetailsContextMapper)
.contextSource(contextSource)
.userSearchFilter(“cn={0}”)
.userSearchBase(“ou=用户”);
}
类MultipleDataAuthoritiesPopulator实现LDAPAuthoriesPopulator{
私人列表授权人;
公共MultipleDataAuthoritiesPopulator(LDAPAuthoriesPopulator…AuthoriesPopulators){
this.authoritespopulators=asList(authoritespopulators);
}
@凌驾

公共收藏你找到你的问题的解决方案了吗?我在寻找完全相同的东西。谢谢。