【问题标题】:Retrieve operational LDAP attributes with Spring Security使用 Spring Security 检索可操作的 LDAP 属性
【发布时间】:2021-06-03 06:53:58
【问题描述】:

我正在使用spring-security-ldap 向我的应用程序添加 LDAP 身份验证。它是这样配置的:

auth.ldapAuthentication()
          .userSearchBase(ldapConfigProperties.getUserSearchBase())
          .userSearchFilter(ldapConfigProperties.getUserSearchFilter())
          .contextSource()
          .managerDn(ldapConfigProperties.getManagerDn())
          .managerPassword(ldapConfigProperties.getManagerPassword())
          .url(ldapConfigProperties.getUrl())
          .and()
          .userDetailsContextMapper(ldapContextMapper);

ldapContextMapper 是一个名为LdapUserContextMapper 的自定义类的实例,它实现了UserDetailsContextMapper

mapUserFromContext() 内部,我使用DirContextOperations 从LDAP 用户检索几个属性来构造一个具体的User POJO。但是,我无法访问像memberOf 这样的操作属性。我尝试了所有可以在网上找到的解决方案,但似乎没有任何效果。

例如,ctx.getObjectAttributes("memberOf") 返回 null。尝试使用自定义 SearchControlsSUBTREE_SCOPE 调用 ctx.search("", "", searchControls) 会产生来自 DirContextAdapternot implemented 异常。

有什么想法吗?

【问题讨论】:

    标签: spring spring-boot spring-security spring-ldap


    【解决方案1】:

    我最终实例化了我自己的ContextSource,然后使用自定义ObjectPostProcessor,正如this issue 中所述。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-08-18
      • 2017-09-25
      • 1970-01-01
      • 1970-01-01
      • 2010-12-10
      • 1970-01-01
      • 2018-10-08
      • 2023-03-20
      相关资源
      最近更新 更多