【发布时间】: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。尝试使用自定义 SearchControls 和 SUBTREE_SCOPE 调用 ctx.search("", "", searchControls) 会产生来自 DirContextAdapter 的 not implemented 异常。
有什么想法吗?
【问题讨论】:
标签: spring spring-boot spring-security spring-ldap