我正在尝试从大型 ldap Active Directory (AD) 组中删除成员。如果组很小,下面的代码将删除成员。但是,如果它更大,它就不起作用,因为 AD 将成员拆分为多个范围相关的属性。
group.removeMember(person.getFullDn());
ldapTemplate.update(group);
我尝试使用如下所示的方法直接访问这些属性。 IncrementalAttributesMapper 允许我获取与范围相关的成员属性列表,即 member;Range=0-1499 并且我尝试从每个属性中删除该人,但效果不佳。我没有收到错误消息,但此人也没有从群组中删除
DirContextOperations ctx = ldapTemplate.lookupContext(group.getDn());
IncrementalAttributesMapper<?> attributesMapper = new DefaultIncrementalAttributesMapper("member");
while (attributesMapper.hasMore()) {
String[] attributes = attributesMapper.getAttributesForLookup();
for (String attribute: attributes ) {
ldapTemplate.lookup(group.getDn(), attributesMapper.getAttributesForLookup(), attributesMapper);
ctx.removeAttributeValue(attribute, person.getDn() );
ldapTemplate.modifyAttributes(ctx);
}
}
希望有人在这方面取得了更大的成功。提前致谢!
最佳答案
我已经找到解决方案 as posted
我收到格式错误的属性错误,直到我意识到 BasicAttribute 需要字符串参数。我错误地向它传递了一个 Name 对象。
ldapTemplate.modifyAttributes(group.getDn(), new ModificationItem[] {
new ModificationItem(
DirContext.REMOVE_ATTRIBUTE,
new BasicAttribute("member", person.getFullDn().toString() ))
});
关于active-directory - 如何从成员超过 1500 人的大型 ldap-ad 组中删除成员,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34004122/