Azure AD GraphServiceClient 扩展不工作
Azure AD GraphServiceClient Extensions not working
我有以下查询来检索使用 GraphServiceClient
和 .net core 2 的用户。
user = await _graphClient.Users[principalName].Request()
.Expand("Extensions")
.GetAsync();
当我 运行 这样做时,我得到以下错误
Microsoft.Graph.ServiceException: Code: generalException Message:
Unexpected exception returned from the service.
只有当我使用以下代码向用户添加 OpenTypeExtension
时才会发生这种情况!
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。
我似乎无法向我的用户添加任何元数据。这样做只是因为 otherEmails
不适用于 GraphServiceClient
并尝试使用任何其他合理的字段给我这个错误:
Tenant does not have a SPO license when updating user
如有任何帮助,我们将不胜感激。
所以对于遇到此问题的任何其他人来说,这似乎是服务客户端中的错误。
下面的代码失败了
user = await _graphClient
.Users[userId]
.Request()
.Expand("Extensions")
.GetAsync();
但此代码有效,只需在单独的调用中请求扩展!
user = await _graphClient
.Users[userId]
.Request()
.GetAsync();
var extensions = await _graphClient.Users[user.Id].Extensions.Request().GetAsync();
user.Extensions = extensions;
希望有人能在我为此浪费的时间里拯救我!
我有以下查询来检索使用 GraphServiceClient
和 .net core 2 的用户。
user = await _graphClient.Users[principalName].Request()
.Expand("Extensions")
.GetAsync();
当我 运行 这样做时,我得到以下错误
Microsoft.Graph.ServiceException: Code: generalException Message: Unexpected exception returned from the service.
只有当我使用以下代码向用户添加 OpenTypeExtension
时才会发生这种情况!
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。
我似乎无法向我的用户添加任何元数据。这样做只是因为 otherEmails
不适用于 GraphServiceClient
并尝试使用任何其他合理的字段给我这个错误:
Tenant does not have a SPO license when updating user
如有任何帮助,我们将不胜感激。
所以对于遇到此问题的任何其他人来说,这似乎是服务客户端中的错误。
下面的代码失败了
user = await _graphClient
.Users[userId]
.Request()
.Expand("Extensions")
.GetAsync();
但此代码有效,只需在单独的调用中请求扩展!
user = await _graphClient
.Users[userId]
.Request()
.GetAsync();
var extensions = await _graphClient.Users[user.Id].Extensions.Request().GetAsync();
user.Extensions = extensions;
希望有人能在我为此浪费的时间里拯救我!