简体   繁体   中英

Active Directory LDAP Authentication using Spring Boot and Java

I'm trying to authenticate with organization ldap server. When I enter the credentials I'm facing this error. Can someone help?

Uncategorized exception occured during LDAP processing; nested exception is javax.naming.NamingException: [LDAP: error code 1 - 000004DC: LdapErr: DSID-0C090A7D, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, v3839]; remaining name 'username=aestools,ou=people'

This is my configuration:

@Override
    public void configure(AuthenticationManagerBuilder auth) throws Exception {
        auth
        .ldapAuthentication().userDnPatterns("username={0},ou=people").contextSource()
        .url("ldap://ldap.example.com:389/dc=ms,ddc=ds,dc=example,dc=com").and().passwordCompare()
        .passwordAttribute("password");

I think you need to authenticate an account that can view the LDAP records or something, maybe this will work

  auth
    .ldapAuthentication()
    .userDnPatterns("username={0},ou=people")
    .contextSource()
    .managerDn("cn=admin,ou=people,dc=ms,dc=ds,dc=example,dc=com")
    .managerPassword("adminPassword123") 
    .url("ldap://ldap.example.com:389/dc=ms,dc=ds,dc=example,dc=com")
    .and()
    .passwordCompare()
    .passwordAttribute("password");

So basically you need to fill in .managerDn() and .managerPassword() with info of the account that has permission to view LDAP server's records. This Spring security LDAP is quite new to me, so sorry if my answer not work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM