Spring LDAP 常见问题
操作属性
如何使用 context.removeAttributeValue() 删除操作属性?
默认情况下,DirContextAdapter 仅读取可见属性。 这是因为操作属性只有在明确要求时才由服务器返回,并且 Spring LDAP 无法知道要请求的属性。 这意味着 DirContextAdapter 不会填充操作属性。 因此,removeAttributeValue 没有任何效果(因为从 DirContextAdapter 的角度来看,它一开始就不存在)。
基本上有两种方法可以做到这一点
-
使用将属性名称作为参数的搜索或查找方法,例如
LdapTemplate#lookup(Name, String[], ContextMapper)。 然后使用在mapFromContext()中返回提供的DirContextAdapter的ContextMapper实现。 -
直接使用
LdapTemplate#modifyAttributes(Name, ModificationItem[]),手动构建ModificationItem数组。