使用 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 异常。

有什么想法吗?

解决方法

我最终实例化了自己的 error: int cannot be dereferenced,然后使用自定义 ContextSource,正如 this issue 中所述。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...