简体   繁体   中英

Spring boot ldap Authentication Error [LDAP: error code 49 - Invalid Credentials]

I am trying to connect to the ldap server to fetch user data using springboot. My spring boot application.properties as

spring.ldap.base=dc=example,dc=com
spring.ldap.password=Secret
spring.ldap.username=uid=admin,ou=user
spring.ldap.urls=ldap://myServerIP:389/
spring.data.ldap.repositories.enabled=true

when I try to get the data using the rest controller I am getting an error of code 49 stating

ERROR 3535 --- [nio-8080-exec-8] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.ldap.AuthenticationException: [LDAP: error code 49 - Invalid Credentials]; nested exception is javax.naming.AuthenticationException: [LDAP: error code 49 - Invalid Credentials]] with root cause

javax.naming.AuthenticationException: [LDAP: error code 49 - Invalid Credentials]

As I am new to ldap data fetching am not sure whether this is caused from the ldap or from the springboot connectivity. If could anyone explain and give me solution would be great

This was caused because, there was a issue on the way I configured the LDAP in application.properties

Actual configuration should be :

spring.ldap.password=secret
spring.ldap.username=cn=admin,dc=example,dc=com
spring.ldap.urls=ldap://myserverIP:389/

And the base should be set in the model class as

@Entry( base = "dc=example,dc=com",objectClasses = {"inetOrgPerson"})
public class ldapUserModel {
//attributes, getters and setters
}

object class should be changed to the object class ypu prefer to search and do the other usual codings.

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