我无法从群组中删除用户。我添加用户没有问题。我没有从myGroup.Members.Remove(用户作为DirectoryObject);收到任何错误。这是一个错误吗?
ActiveDirectoryClient client = AuthenticationHelper.GetActiveDirectoryClient();
User user = (User)await client.Users.GetByObjectId(userID).ExecuteAsync();
IGroup myIGroup = await client.Groups.GetByObjectId(objectId).ExecuteAsync();
Group myGroup = (Group)myIGroup;
if (myGroup != null && user != null)
{
try
{
switch (myAction)
{
case "Delete":
myGroup.Members.Remove(user as DirectoryObject);
break;
case "Add":
myGroup.Members.Add(user as DirectoryObject);
break;
}
await myGroup.UpdateAsync();