英文:
Spring boot ldap Authentication Error [LDAP: error code 49 - Invalid Credentials]
问题
我正在尝试使用Spring Boot连接到LDAP服务器以获取用户数据。我的Spring Boot应用的application.properties配置如下:
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
当我尝试使用REST控制器获取数据时,我遇到了一个代码为49的错误,错误信息如下:
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]
由于我对LDAP数据获取不是很熟悉,我不确定这是由LDAP还是Spring Boot连接引起的。如果有人能解释并给出解决方案,将会非常棒。
英文:
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
答案1
得分: 0
这是因为在 application.properties 中配置 LDAP 时出现了问题。
实际配置应为:
spring.ldap.password=secret
spring.ldap.username=cn=admin,dc=example,dc=com
spring.ldap.urls=ldap://myserverIP:389/
而基本设置应在模型类中进行设置:
@Entry(base = "dc=example,dc=com", objectClasses = {"inetOrgPerson"})
public class ldapUserModel {
// 属性、getter 和 setter 方法
}
将对象类更改为您喜欢的对象类,然后进行其他常规编码。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论