Сбой аутентификации Ldap при загрузке Spring с кодом ошибки LDAP 49 — 80090308 данные 52e

Я пытаюсь использовать аутентификацию пользователя LDAP в своем веб-приложении с помощью весенней безопасности, но получаю error 52e, ниже мой код аутентификации ldap для весенней безопасности:

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("P@ssw0rd")
   .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": "/"
}

Пожалуйста, помогите мне.


person Sai Nikhil    schedule 14.09.2017    source источник
comment
Вы уверены, что можете использовать пробелы в имени? SL-пользователи   -  person Aruna Karunarathna    schedule 15.09.2017
comment
Я попытался удалить пробел в имени ou и сделать ou как SLUsers, но все та же ошибка Ldap 52e.   -  person Sai Nikhil    schedule 15.09.2017
comment
(www-01.ibm.com/support/docview.wss?uid =swg21290631) 52e приходит для неверных учетных данных. Таким образом, пользователь доступен. Вы уверены, что используете правильные учетные данные?. Вы хешировали/зашифровывали пароли?   -  person Aruna Karunarathna    schedule 15.09.2017
comment
Нет, я не зашифровал пароль   -  person Sai Nikhil    schedule 15.09.2017


Ответы (1)


Существует еще один простой способ аутентификации ldap. Я использовал приведенный ниже код для аутентификации ldap. Это сработало для меня как шарм:

            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;
             }
            }
person Sai Nikhil    schedule 13.10.2017