active-directory - 如何从成员超过 1500 人的大型 ldap-ad 组中删除成员

标签 active-directory spring-ldap

我正在尝试从大型 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/

相关文章:

java - 在 Active Directory LDAP 中添加具有密码的用户

grails - 如何自定义现有Grails插件功能,修改doWithSpring方法的行为

grails - 合并的LdapTemplate在上下文验证期间停顿了几分钟

powershell - 搜索帐户时获得更好的性能

java - 如何通过 Java 代码在没有完整 CN/DN 的情况下连接 Active Directory

Python ldap3代码从SID获取用户名

grails - 在 Grails 服务中注入(inject) LdapTemplate 以返回用户详细信息会导致空指针异常

c# - 从 AD 获取用户详细信息很慢

javascript - 通过 javascript 或 HTML 5 的 Kerberos

spring-mvc - LDAP - 上下文源的 AD 用户名密码配置