Приложение Spring-Boot для аутентификации в Active Directory (AD) - PullRequest
0 голосов
/ 09 января 2020

Active directory для меня очень нова, может кто-нибудь помочь мне настроить WebSecurityConfig для правильной аутентификации с AD в Spring Security.

AD похож на:

CN=myCN,OU=OU_1,OU=OU_2,DC=example,DC=com

Я использую этот учебник https://spring.io/guides/gs/authenticating-ldap/, и у меня есть метод configure (это код kotlin):

    @Throws(Exception::class)
    override fun configure(auth: AuthenticationManagerBuilder) {
        auth
                .ldapAuthentication()
                .userDnPatterns("uid={0},ou=OU_1,ou=OU_2")
                .groupSearchBase("")
                .userSearchFilter("CN=myCN")
                .contextSource()
                .url("ldap://{targeted AD IP:389}/dc=example,dc=com")
                .and()
                .passwordCompare()
                .passwordEncoder(LdapShaPasswordEncoder())
                .passwordAttribute("userPassword")
    }

Проблема в том, что я не могу пройти проверку подлинности с этим код. Я получаю сообщение об ошибке:

Failed to bind as uid=username,CN=myCN,OU=OU_1, OU=OU_2: org.springframework.ldap.AuthenticationException: [LDAP: error code 49 - 80090308: LdapErr: DSID-0C090400, comment: AcceptSecurityContext error, data 52e, v1db1]; nested exception is javax.naming.AuthenticationException: [LDAP: error code 49 - 80090308: LdapErr: DSID-0C090400, comment: AcceptSecurityContext error, data 52e, v1db1]

Я уверен, что пользователь существует, и учетные данные, которые я использую, верны.

...