gpt4 book ai didi

c# - Azure GraphClient 库从组中删除用户

转载 作者:太空狗 更新时间:2023-10-29 22:10:36 28 4
gpt4 key购买 nike

Azure Graph 客户端库已于 12 月 22 日更新,并且修复了将用户添加到组的方法。

Azure Active Directory Graph Client 2.0 - Context is not currently tracking the entity

但是可以从组中删除用户吗?

我尝试过这个方法:

{groupObject}.Members.Remove({entityObject} as DirectoryObject); 
await myGroup.UpdateAsync();

它不会失败,但用户不会从组中删除。

最佳答案

我找到了解决方法。也许这会有所帮助:

public void RemoveUserFromGroup(Group group, User user)
{
var internalGroup = _activeDirectoryClient.Context.CreateQuery<GraphClient.Internal.Group>("groups/" + group.ObjectId).ToList().First();

var internalUser = _activeDirectoryClient.Context.CreateQuery<GraphClient.Internal.User>("users/" + user.ObjectId).ToList().First();

_activeDirectoryClient.Context.DeleteLink(internalGroup, "members", internalUser);
_activeDirectoryClient.Context.SaveChanges();
}

关于c# - Azure GraphClient 库从组中删除用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27710557/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com