Azure Active Directory Graph Client 2.0 - 上下文当前未跟踪实体 [英] Azure Active Directory Graph Client 2.0 - Context is not currently tracking the entity

查看:22
本文介绍了Azure Active Directory Graph Client 2.0 - 上下文当前未跟踪实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近安装了 Azure Active Directory Graph Client Library 2.0.2 Nuget 包,但无法将成员添加到组中 将组添加到组或将用户添加到组 我在 AddLink 时收到以下错误函数被调用:

I have recently installed the Azure Active Directory Graph Client Library 2.0.2 Nuget package and am unable to add Members to Groups both adding a group to a group or adding a user to a group I am getting the following error when the AddLink function is called:

[System.InvalidOperationException] = {上下文当前没有跟踪实体."}

"[System.InvalidOperationException] = {"The context is not currently tracking the entity."}

我的代码:

IGroup group = azureClient.Groups.GetByObjectId("Guid here").ExecuteAsync().Result;
IGroup groupToAdd = azureClient.Groups.GetByObjectId("Guid here").ExecuteAsync().Result;
azureClient.Context.AddLink(group, "Members", groupToAdd);
azureClient.Context.SaveChanges();

在进行 Google 搜索时,我无法找到与 Azure Active Directory Graph Client Library 相关的任何提及此错误的信息,因此非常感谢您对此的任何帮助.

I have been unable to find any mention of this error in relation to the Azure Active Directory Graph Client Library from doing Google searches so any help on this would be much appreciated.

推荐答案

我们刚刚发布了 Graph 客户端库的更新,解决了这个问题.您现在应该能够将成员添加到组中.该机制与使用 AddLinks 有点不同(希望更简单).

We’ve just released an update to the Graph client library, that fixes this problem. You should now be able to add members to groups. The mechanism is a little different from using AddLinks (and hopefully simpler).

我们还有一个描述客户端库的新博客,它讨论了这个和许多其他事情:http://blogs.msdn.com/b/aadgraphteam/archive/2014/12/12/annoucing-azure-ad-graph-api-client-library-2-0.aspx

We also have a new blog describing the client library which talks about this and many other things: http://blogs.msdn.com/b/aadgraphteam/archive/2014/12/12/announcing-azure-ad-graph-api-client-library-2-0.aspx

作为参考,将成员添加到组:

For reference, to add a member to a group:

{groupObject}.Members.Add({entityObject} as DirectoryObject);

{groupObject}.Members.Add({entityObject} as DirectoryObject);

例如,要使用新用户成员更新群组:

So for example, to update a group with a new user member:

myGroup.Members.Add(userToBeAdded as DirectoryObject);等待 myGroup.UpdateAsync();

myGroup.Members.Add(userToBeAdded as DirectoryObject); await myGroup.UpdateAsync();

注意:相同的构造可用于将用户添加到 DirectoryRole 对象.组和用户可以添加到组中,但是,目前只能将用户添加到 DirectoryRole.

NOTE: The same construct can be used to add users to a DirectoryRole object. Groups and users may be added to a group, however, for now, only users can be added to a DirectoryRole.

希望这会有所帮助,

这篇关于Azure Active Directory Graph Client 2.0 - 上下文当前未跟踪实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆