繁体   English   中英

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

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

通过Apache Directory Studio检索的LDAP服务器层次结构:

根DSE:

DC =公司,DC = COM

OU =办事处

OU =地区办事处

OU = Region1 Office

OU =用户

CN = Jayesh Mulwani

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}))");
    }
}

在Tomcat上安装了应用程序后,我输入了用户名及其密码,但是身份验证失败,并且未提示任何错误。

有人可以协助我采取这种方法,还是指定我在这里是否缺少什么?

我通过添加以下两个条件解决了该问题

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

我引用了这个示例来解决此问题, 网址为http://www.jcombat.com/spring/spring-security-ldap-authentication

暂无
暂无

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

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