0
私は春のセキュリティが、 error 52eを取得して自分のWebアプリケーションでLDAPユーザ認証を使用しようとしています

は、以下の私の春のセキュリティLDAP認証コードです:春ブーツLDAPエラーコードで失敗LDAP認証49から80090308データ52E

protected void configure(AuthenticationManagerBuilder auth) throws Exception { 
    auth.ldapAuthentication() 
    .contextSource().url("ldap://192.168.1.5:389/DC=zonetest,DC=lk") 
    .managerDn("[email protected],DC=zonetest,DC=lk").managerPassword("[email protected]") 
    .and() 
    .userSearchBase("OU=SL Users") 
    .userSearchFilter("(CN={0})"); 
} 

私のLDAP構造を参照するためのスクリーンショットで提供される:

私は私を助けてください郵便配達クライアントに

{ 
    "timestamp": 1505368170503, 
    "status": 401, 
    "error": "Unauthorized", 
    "message": "[LDAP: error code 49 - 80090308: LdapErr: DSID-0C0903C5, comment: AcceptSecurityContext error, data 52e, v2580\u0000]; nested exception is javax.naming.AuthenticationException: [LDAP: error code 49 - 80090308: LdapErr: DSID-0C0903C5, comment: AcceptSecurityContext error, data 52e, v2580\u0000]", 
    "path": "/" 
} 

をこのエラーを取得しています。

+0

はあなたがOU名にスペースを使用することができてもよろしいです?。 "SL Users" –

+0

私はou名のスペースを削除し、ouを "SLUsers"として作成しましたが、まだ同じLdap 52eエラーを試みました。 –

+0

(http://www-01.ibm.com/support/docview.wss?uid=swg21290631)52eは無効な信任状のために来るので、ユーザーは利用可能です.URLは正しい信任状を使用していますか?パスワードをハッシュ/暗号化しましたか? –

答えて

0

のLDAP authentication.iがLDAP authentication.Thisを行うために以下のコードを使用するために、別の簡単な方法がありますが魔法のように私の仕事:

  package app.config;  
      import org.springframework.beans.factory.annotation.Value; 
      import org.springframework.context.annotation.Bean; 
      import org.springframework.context.annotation.Configuration; 
      import org.springframework.security.authentication.AuthenticationManager; 
      import org.springframework.security.authentication.AuthenticationProvider; 
      import org.springframework.security.authentication.ProviderManager; 
      import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; 
      import org.springframework.security.config.annotation.web.builders.HttpSecurity; 
      import org.springframework.security.config.annotation.web.builders.WebSecurity; 
      import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 
      import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 
      import org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAuthenticationProvider; 
      import java.util.Arrays; 

      @Configuration 
      @EnableWebSecurity 
      public class WebSecurityConfigAD extends WebSecurityConfigurerAdapter { 

      @Value("${ad.domain}") 
      private String AD_DOMAIN; 

      @Value("${ad.url}") 
      private String AD_URL; 

      @Override 
      protected void configure(HttpSecurity http) throws Exception { 
       http.authorizeRequests().anyRequest().authenticated().and().httpBasic(); 
      } 

      @Override 
      protected void configure(AuthenticationManagerBuilder authManagerBuilder) throws Exception { 
       authManagerBuilder.authenticationProvider(activeDirectoryLdapAuthenticationProvider()).userDetailsService(userDetailsService()); 
      } 

      @Bean 
      public AuthenticationManager authenticationManager() { 
       return new ProviderManager(Arrays.asList(activeDirectoryLdapAuthenticationProvider())); 
      } 
      @Bean 
      public AuthenticationProvider activeDirectoryLdapAuthenticationProvider() { 
       ActiveDirectoryLdapAuthenticationProvider provider = new ActiveDirectoryLdapAuthenticationProvider(AD_DOMAIN, AD_URL); 
       provider.setConvertSubErrorCodesToExceptions(true); 
       provider.setUseAuthenticationRequestCredentials(true); 

       return provider; 
      } 
      }