简体   繁体   English

使用具有Spring Security的LDAP用户搜索查询无法通过LDAP服务器对用户进行身份验证

[英]Unable to Authenticate a User with an LDAP Server using LDAP User Search Query with Spring Security

LDAP Server Hierarchy as retrieved via Apache Directory Studio: 通过Apache Directory Studio检索的LDAP服务器层次结构:

Root DSE: 根DSE:

DC=company,DC=com DC =公司,DC = COM

OU=Offices OU =办事处

OU=Region Offices OU =地区办事处

OU=Region1 Office OU = Region1 Office

OU=Users OU =用户

CN=Jayesh Mulwani CN = Jayesh Mulwani

WebSecurity is enabled as a part of below class: WebSecurity作为以下类的一部分启用:

public class LDAPSecurityConfig extends WebSecurityConfigurerAdapter{
    protected void configure(AuthenticationManagerBuilder authenticationManagerBuilder) throws Exception {                  
            authenticationManagerBuilder.ldapAuthentication()
            .contextSource().url("ldap://server-url/CN=auth_support,OU=Misc,DC=company,DC=com")
            .managerDn("username").managerPassword("password")
            .and()
            .userSearchBase("OU=Offices,DC=company,DC=com")
            .userSearchFilter("(&(objectClass=user)(cn={0}))");
    }
}

Once the application is setup on tomcat, i enter the username along with its password but the authentication fails and no error is prompted. 在Tomcat上安装了应用程序后,我输入了用户名及其密码,但是身份验证失败,并且未提示任何错误。

Can someone please assist me with the approach or specify if i'm missing something here ? 有人可以协助我采取这种方法,还是指定我在这里是否缺少什么?

I have fixed the problem by adding the below two conditions 我通过添加以下两个条件解决了该问题

.groupSearchFilter("(&(objectClass=group)(AccountName={0}))")
.groupSearchBase("CN=DEPT_All_Employees,OU=DepartmentSecurityGroups,OU=Resources,DC=company,DC=com")

I referred this example to fix the issue http://www.jcombat.com/spring/spring-security-ldap-authentication 我引用了这个示例来解决此问题, 网址为http://www.jcombat.com/spring/spring-security-ldap-authentication

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Spring安全性配置来认证ldap用户 - Spring security configuration to authenticate ldap user 如何使用Spring Ldap在Active Directory中对用户进行身份验证和搜索 - How authenticate and search user in Active Directory using Spring Ldap 如何使用spring Security通过基于邮件和uid的LDAP对用户进行身份验证? - How to authenticate a user from LDAP based on mail and by uid with spring Security? Spring 安全性 LDAP 身份验证应该只验证一个用户 - Spring Security LDAP Authentication should authenticate only one user 如何使用ping访问权限和在标头中传递的用户名,使用Spring Security对预认证的LDAP用户进行身份验证? - How do I authenticate a preauthenticated LDAP user using spring security using ping access and username passed in the header? 如何使用spring-data-ldap对ladp用户进行身份验证? - How to authenticate ladp user using spring-data-ldap? 如何使用带有LDAP的Spring Security获得用户信息 - How can I get the user information using Spring Security with LDAP 如何使用密码在Ldap中验证用户 - how to authenticate a user in Ldap using password Spring Security LDAP获取用户给定名称 - Spring Security LDAP get User Given Name 无法使用Spring Security通过LDAP验证到目录(Active Directory) - Unable to authenticate via LDAP to directory (Active Directory) with Spring Security
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM