Azure Graph api客户端从组中删除成员

时间:2015-11-13 07:20:17

标签: azure azure-ad-graph-api

我无法从群组中删除用户。我添加用户没有问题。我没有从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();

0 个答案:

没有答案