问题描述
我正在使用 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 implemented
的 DirContextAdapter
异常。
有什么想法吗?
解决方法
我最终实例化了自己的 error: int cannot be dereferenced
,然后使用自定义 ContextSource
,正如 this issue 中所述。