使用 Microsoft Graph 查询 AzureAD Graph 扩展属性

Querying AzureAD Graph extension attributes with Microsoft Graph(使用 Microsoft Graph 查询 AzureAD Graph 扩展属性)
本文介绍了使用 Microsoft Graph 查询 AzureAD Graph 扩展属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从 Azure AD Graph API 迁移到 Microsoft Graph,因为它现在已被弃用.以前,可以使用 Microsoft.Azure.ActiveDirectory.GraphClient .GetExtendedProperties(); 调用来针对用户访问扩展属性,例如:

var client = new ActiveDirectoryClient(serviceRoot, async () => await GetToken());var user = await client.Users["user id..."].ExecuteAsync();var 属性 = user.GetExtendedProperties();

我需要用 Microsoft Graph 中的等效调用来复制它.

我查看了

C# 代码示例:

var user = await graphClient.Users["98****c9-f062-48e2-8ced-22cb6****ce"].要求().Select("id,extension_6d****fbf1fe4bc38a5a145520****89_policy,displayName").GetAsync();

I am in the process of migrating away from Azure AD Graph API to Microsoft Graph since it is now deprecated. Previously it was possible to access extended properties against a user using Microsoft.Azure.ActiveDirectory.GraphClient .GetExtendedProperties(); call e.g:

var client = new ActiveDirectoryClient(serviceRoot, async () => await GetToken());
var user = await client.Users["user id..."].ExecuteAsync();
var properties = user.GetExtendedProperties();

I need to replicate this with equivalent calls in Microsoft Graph.

I have looked at the schemaExtensions endpoint, e.g:

GET all extensions:

/v1.0/schemaExtensions

But this doesn't appear to return the same extensions data that the AD Graph Client did.

GET user with ext:

v1.0/users/[user id]?$expand=extensions&$select=id,extension_[application id]_myExtension,onPremisesExtensionAttributes,displayName,jobTitle,identities

Where extension_[application id]_myExtension is an example extension in the format:

extension_appid_extensionname

And this doesn't return the custom extension data for the user (other properties work fine however).

How can we migrate extended properties from AD Graph Client to Microsoft Graph?

解决方案

SchemaExtensions is different from extensionProperty. What you mentioned should be extensionProperty in Microsoft Graph.

You can use List extensionProperties to get all extensions.

Your request v1.0/users/[user id]?$expand=extensions&$select=id,extension_[application id]_myExtension,onPremisesExtensionAttributes,displayName,jobTitle,identities should be correct.

Please make sure that the application id should remove all -. The extension property format is extension_[application id without "-"]_myExtension.

For example:

GET https://graph.microsoft.com/v1.0/me?$select=id,extension_6d****fbf1fe4bc38a5a145520****89_policy,displayName

Response:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users(id,extension_6d****fbf1fe4bc38a5a145520****89_policy,displayName)/$entity",
    "id": "98****c9-f062-48e2-8ced-22cb68****ce",
    "displayName": "Allen Wu",
    "extension_6d****fbf1fe4bc38a5a145520****89_policy": "readwrite"
}

The C# code sample:

var user = await graphClient.Users["98****c9-f062-48e2-8ced-22cb6****ce"]
    .Request()
    .Select("id,extension_6d****fbf1fe4bc38a5a145520****89_policy,displayName")
    .GetAsync();

这篇关于使用 Microsoft Graph 查询 AzureAD Graph 扩展属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)