问题描述
我有以下查询,用于使用具有.net core 2的GraphServiceClient
检索用户.
I have the following query to retrieve a User using the GraphServiceClient
with .net core 2.
user = await _graphClient.Users[principalName].Request()
.Expand("Extensions")
.GetAsync();
运行此命令时,出现以下错误
When I run this I get the following error
仅当我使用以下代码向用户添加了OpenTypeExtension
时,才会发生这种情况!
This only happens when I have added a OpenTypeExtension
to the user using the following code!
extension = new OpenTypeExtension
{
ExtensionName = AzureADExtensions.UserConstants.ExtensionName,
AdditionalData = new Dictionary<string, object>
{
{"OtherEmail", externalUser.Email},
{"OtherRole" , externalUser.Roles.FirstOrDefault()}
}
};
await _graphClient.Users[user.Id].Extensions.Request()
.AddAsync(extension);
我现在开始真的对Azure AD感到厌烦.
I am starting to get really getting fed up with Azure AD now.
我似乎无法向用户添加任何元数据.仅这样做是因为otherEmails
与GraphServiceClient
不兼容,并且尝试使用任何其他明智的字段都会给我以下错误:
I can't seem to add any meta data to my users. Only doing this because otherEmails
does not work with the GraphServiceClient
and trying to use any other sensible fields gives me this error:
任何帮助将不胜感激.
Any help would be appreciated.
推荐答案
因此,对于遇到此问题的任何其他人,这似乎是服务客户端中的错误.
So for anyone else that come across this, it seems to be an a bug in the service client.
下面的代码失败
user = await _graphClient
.Users[userId]
.Request()
.Expand("Extensions")
.GetAsync();
但是此代码有效,仅在单独的调用中请求扩展即可!
But this code works, just by requesting the extensions in a separate call!
user = await _graphClient
.Users[userId]
.Request()
.GetAsync();
var extensions = await _graphClient.Users[user.Id].Extensions.Request().GetAsync();
user.Extensions = extensions;
希望我在此上浪费的时间可以节省一个人!
Hope that save's someone the time I lost on this!
这篇关于Azure AD GraphServiceClient扩展不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!