【问题标题】:How do I remove a member from a large ldap-ad group with over >1500 members如何从具有超过 1500 个成员的大型 ldap-ad 组中删除成员
【发布时间】: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


    【解决方案1】:

    我有解决办法as posted

    我得到一个 malformed attribute 错误,直到我意识到 BasicAttribute 需要字符串参数。我错误地将 Name 对象传递给它。

    ldapTemplate.modifyAttributes(group.getDn(), new ModificationItem[] {
                new ModificationItem(
                    DirContext.REMOVE_ATTRIBUTE,
                    new BasicAttribute("member", person.getFullDn().toString() ))
            });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-10-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-26
      相关资源
      最近更新 更多