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

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

问题描述

我最近安装了Azure Active Directory Graph Client Library 2.0.2 Nuget程序包,无法将成员添加到组中,既不能将组添加到组中,也不能将用户添加到组中,我在添加链接时遇到以下错误函数称为:

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();

我找不到与Azure Active Directory图形客户端库有关的此错误的任何提及

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).

我们还有一个新的博客描述了客户端库,其中讨论了此内容以及许多其他内容:< a href = http://blogs.msdn.com/b/aadgraphteam/archive/2014/12/12/announcing-azure-ad-graph-api-client-library-2-0.aspx rel = noreferrer > http://blogs.msdn.com/b/aadgraphteam/archive/2014/12/12/announcing-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为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天全站免登陆