【发布时间】:2015-12-01 20:11:31
【问题描述】:
我正在尝试从大型 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);
}
}
希望有人在这方面取得了更大的成功。提前致谢!
【问题讨论】:
标签: active-directory spring-ldap