首页 > 解决方案 > Spring LDAP - 错误代码 32 - 问题 2001 (NO_OBJECT)

问题描述

大家下午好

我正在为我的 Spring Web 应用程序实现与 Active Directory 的 LDAP 连接。

我的项目依赖项是:spring-security-ldap & spring-ldap-core

这是我的课程 WebSecurityConfig

@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)
public class WebSecurityConfig extends WebSecurityConfigurerAdapter{

    @Value("${ldap.principal.encrypted.password}")
    private String ldapPrincipalPassword;

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

    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        auth.ldapAuthentication()
        .userSearchBase("OU=Technical_department,OU=Users,DC=society,DC=loc")
        .userSearchFilter("(sAMAccountName={0})")
        .contextSource()
            .url("ldap://SPCL004.society.loc:389/DC=society,DC=loc")
            .managerDn("CN=admin_account,OU=Service accounts,DC=society,DC=loc")
            .managerPassword(ldapPrincipalPassword);
    }   
}

当我想使用 sAMAccountName 登录时:“PDURAND”和我的密码,我仍然有这个错误:

Caused by: javax.naming.NameNotFoundException: [LDAP: error code 32 - 0000208D: NameErr: DSID-03100241, problem 2001 (NO_OBJECT), data 0, best match of:
    'DC=society,DC=loc'

我检查了与 AD Explorer 的连接并使用相同的参数,我可以在 AD 树中找到用户:CN=DURAND Patrick,OU=Technical_department,OU=Users,DC=society,DC=loc

预先感谢您的帮助

标签: javaspringldap

解决方案


推荐阅读