操作属性

如何使用 删除操作属性?context.removeAttributeValue()

默认情况下,仅读取可见属性。这是因为服务器只有在明确请求时才会返回操作属性,并且Spring LDAP无法知道要请求的属性。这意味着 不会填充操作属性。因此,它没有任何影响(因为从的角度来看,它一开始就不存在)。DirContextAdapterDirContextAdapterremoveAttributeValueDirContextAdapter

基本上有两种方法可以做到这一点:

  • 使用将属性名称作为参数的搜索或查找方法,例如 。然后使用返回 中提供的实现。LdapTemplate#lookup(Name, String[], ContextMapper)ContextMapperDirContextAdaptermapFromContext()

  • 直接使用,手动构建阵列。LdapTemplate#modifyAttributes(Name, ModificationItem[])ModificationItem