【问题标题】:Unable to Authenticate a User with an LDAP Server using LDAP User Search Query with Spring Security无法使用带有 Spring Security 的 LDAP 用户搜索查询来验证具有 LDAP 服务器的用户
【发布时间】:2018-11-03 15:48:14
【问题描述】:

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

根 DSE:

DC=公司,DC=com

OU=办公室

OU=地区办事处

OU=Region1 办事处

OU=用户

CN=贾耶什·穆尔瓦尼

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上设置应用程序后,我输入用户名及其密码,但身份验证失败并且没有提示错误。

有人可以帮助我解决方法或指定我是否在这里遗漏了什么吗?

【问题讨论】:

  • 没有提示错误但是能看到server.log中抛出的错误吗?
  • 服务器是远程服务器,我无权访问它。

标签: spring spring-security ldap ldap-query


【解决方案1】:

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

.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

【讨论】:

    猜你喜欢
    • 2014-09-20
    • 2012-09-04
    • 2012-06-19
    • 2013-09-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-21
    • 2013-04-17
    相关资源
    最近更新 更多