从组中删除成员

您可以通过从组的 member 属性中删除某个成员的可分辨名称,来从组中删除该成员。要删除可分辨名称,请用要删除的成员的可分辨名称调用 Remove 方法。有关 member 属性的详细信息,请参阅 MSDN Library(网址为 https://go.microsoft.com/fwlink/?LinkID=27252)中“Active Directory Schema SDK(Active Directory 架构 SDK)”文档中的“Member(成员)”主题。

以下示例显示如何从组中删除成员。可以通过先找到要删除的用户,然后调用 Remove 方法,完成此任务。

// Bind to the group.
DirectoryEntry group = new DirectoryEntry(groupDN);

// Remove the user from the group.
group.Properties["member"].Remove(userDN);

// Commit the changes to the directory.
group.CommitChanges();

另请参见

参考

PropertyValueCollection
System.DirectoryServices

概念

组管理

Send comments about this topic to Microsoft.

版权所有 (C) 2007 Microsoft Corporation。保留所有权利。