2016-08-15 21 views
1

DefaultLdapAuthoritiesPopulatorは検索スコープを "ONE_LEVEL"に設定しますが、ユーザーが所属するグループのリストを取得するには "SUBSCOPE"を検索する必要があります。設定でLdapAuthoritiesPopulatorをカスタマイズする

私は「設定」スタイルのスプリング設定(コードではなくXML)に従っています。カスタムLdapAuthoritiesPopulatorをXMLで設定する方法の例がたくさんありますが、コードでそれを行う方法に固執しています。ここで

は、私がこれまで持っているものです。

@EnableWebSecurity 
public class SecurityConfig extends WebSecurityConfigurerAdapter { 

    @EnableWebSecurity 
    public class SecurityConfig extends WebSecurityConfigurerAdapter { 

     @Autowired 
     public void configure(AuthenticationManagerBuilder auth) throws Exception { 
      auth.ldapAuthentication() 
       .contextSource().url("ldap://ldap.company.org/") 
       .and() 
        .userSearchBase("o=company.org,c=us") 
        .userSearchFilter("(uid={0})") 
        .groupSearchBase("o=company.org,c=us") 
        .groupSearchFilter("(&(objectClass=groupOfUniqueNames)(uniqueMember={0}))"); 
    } 

    @Override 
    protected void configure(HttpSecurity http) throws Exception { 
     http.formLogin().and().authorizeRequests() 
      .antMatchers("/api/**").authenticated() 
      .anyRequest().permitAll(); 
    } 
} 

欠けている私はDefaultLdapAuthoritiesPopulatorに検索範囲を設定できるようにする必要があるということです。クラス自体は "setSearchSubtree"メソッドを公開しますが、LdapAuthenticationProviderConfigurerはそれを設定する方法を提供しません。

提案がありますか?あなたの検索を開始する前に

final SearchControls searchControls = new SearchControls(); 
searchControls.setSearchScope(SearchControls.SUBTREE_SCOPE); 

+0

ソリューションを見つけましたか? – Saita

答えて

0

はあなたのような何かを追加する必要があります。 「コントロール」と呼ばれるのは私(LDAPの人)以外の理由ですが、それがSpringの役割です。

-jim

+1

私はOPと同じ問題を抱えていますが、答えが役に立たない。どのようにして、SearchControlをこれらの設定ビルダーに至るまで伝えるべきでしょうか? – Saita

関連する問題