【发布时间】:2011-10-01 20:59:49
【问题描述】:
我有代码:
public bool RemoveUserFromAdministratorsGroup(UserPrincipal oUserPrincipal, string computer)
{
try
{
PrincipalContext oPrincipalContext = new PrincipalContext(ContextType.Machine, computer, null, ContextOptions.Negotiate, _sServiceUser, _sServicePassword);
GroupPrincipal oGroupPrincipal = GroupPrincipal.FindByIdentity(oPrincipalContext, "Administrators");
oGroupPrincipal.Members.Remove(oUserPrincipal);
oGroupPrincipal.Save();
return true;
}
catch
{
return false;
}
}
它没有任何例外地工作。但是当我再次运行我的应用程序时,我会在我的列表视图中看到这个用户。因此,该用户并未被删除。
【问题讨论】:
标签: c# active-directory account-management