首页 > 解决方案 > 使用 uniqueMember 属性的 Spring LDAP 身份验证

问题描述

当我尝试使用uid={0},ou=Groups进行身份验证时,我可以成功登录,但当我尝试将模式缩小到特定组时却不能。
uid={0},CN=ROM,OU=USER,OU=APPOU,ou=组

我可能需要使用 uniqueMember 属性,但找不到方法。如何通过仅使用他/她的 uid 来验证具有组的 uniqueMember 属性的用户?

LDAP 组

@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth
        .ldapAuthentication()
        .contextSource()
            .url("ldapUrl")
                .managerDn("username")
                .managerPassword("password")
            .and()
                .userDnPatterns("uid={0},CN=ROM,OU=USER,OU=APPOU,ou=Groups");
}

标签: spring-bootspring-ldapspring-security-ldap

解决方案


以下是感兴趣的人的方式:

 public void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth
    .ldapAuthentication()
    .contextSource()
        .url(ldapUrl")
            .managerDn("username")
            .managerPassword("password")
        .and()
            .userSearchFilter("uid={0}")
            .groupSearchBase("CN=ROM,OU=USER,ou=APPOU,ou=Groups")
            .groupSearchFilter("uniqueMember{0}");

}


推荐阅读