使用 Spring Security 检索可操作的 LDAP 属性

问题描述

我正在使用 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。尝试使用自定义 ctx.search("","",searchControls)SearchControls 调用 SUBTREE_SCOPE 会产生 not implementedDirContextAdapter 异常。

有什么想法吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)