2014-09-29 121 views
0

我想知道使用Spring LDAP 1.3.1从组中删除用户(不删除用户本身)的最佳方式。 (Spring LDAP版本在这里很重要,因为我现在不能升级,我不使用ODM)。Spring LDAP - 从组中删除用户

我试过这个,但它不起作用。该用户的memberOf属性被删除,但用户条目保留在该组中。

public void disable(User user) { 
    Name dn = buildDn(user.getUsername()); 

    Attribute attr = new BasicAttribute("memberOf"); 
    ModificationItem item = new ModificationItem(DirContext.REMOVE_ATTRIBUTE, attr); 

    ldapTemplate.modifyAttributes(dn, new ModificationItem[] { item }); 
} 

任何帮助将不胜感激。

回答

0

如果要从组中删除用户,还必须将其从此组的成员属性中删除。