如何使用 MS Graph 在 Azure AD 中获取目录扩展
How to obtain a directory extension in Azure AD using MS Graph
我正在尝试查询添加到 Azure AD 中的用户对象的自定义目录扩展。我正在使用找到的解决方案 here.
我能够使用 UserProfileController 获取 属性 并更新模型以具有我们的自定义扩展 属性(请参阅下面的两个代码片段)。
Models/UserProfile.cs
public class UserProfile
{
public string DisplayName { get; set; }
public string GivenName { get; set; }
public string Surname { get; set; }
public string extension_ExtId_ExtName { get; set; }
}
View/UserProfile.cshtml
@model App.Models.UserProfile
<h2>@ViewBag.Title.</h2>
<table class="table table-bordered table-striped">
<tr>
<td>Display Name</td>
<td>@Model.DisplayName</td>
</tr>
<tr>
<td>First Name</td>
<td>@Model.GivenName</td>
</tr>
<tr>
<td>Last Name</td>
<td>@Model.Surname</td>
</tr>
<tr>
<td>Employee Id</td>
<td>@Model.extension_ExtId_ExtName</td>
</tr>
</table>
@if (ViewBag.ErrorMessage == "AuthorizationRequired")
{
<p>You have to sign-in to see your profile. Click @Html.ActionLink("here", "Index", "UserProfile", new { reauth = true }, null) to sign-in.</p>
}
@if (ViewBag.ErrorMessage == "UnexpectedError")
{
<p>An unexpected error occurred while retrieving your profile. Please try again. You may need to sign-in.</p>
}
我的目标是让扩展 extension_ExtId_ExtName
出现在用户列表中。我正在尝试使用解决方案的 UsersController
和视图来获取此信息,但似乎无法修改 Microsoft Graph API 用户模型。该模型设置为 Microsoft Graph 客户端控制的 IEnumerable<User>
。
如何添加我的自定义扩展以便我也可以从用户对象中检索它?
我已经确认我可以通过用户对象获取它,方法是转到 Graph Explorer 并将我的请求 URL 设置为:
https://graph.microsoft.com/beta/users('{user@email.com}')?select=extension_EXTENSION-ID_extensionName
谢谢
我认为这里的部分问题是您将两个不同的 API 混为一谈。还有就是Microsoft Graph API and the Azure Active Directory Graph API;这是两个完全不同的 API。虽然它们之间有很多功能重叠,但它们之间的调用不可互换。
我建议改为查看这些 Microsoft Graph API 示例:
我正在尝试查询添加到 Azure AD 中的用户对象的自定义目录扩展。我正在使用找到的解决方案 here.
我能够使用 UserProfileController 获取 属性 并更新模型以具有我们的自定义扩展 属性(请参阅下面的两个代码片段)。
Models/UserProfile.cs
public class UserProfile
{
public string DisplayName { get; set; }
public string GivenName { get; set; }
public string Surname { get; set; }
public string extension_ExtId_ExtName { get; set; }
}
View/UserProfile.cshtml
@model App.Models.UserProfile
<h2>@ViewBag.Title.</h2>
<table class="table table-bordered table-striped">
<tr>
<td>Display Name</td>
<td>@Model.DisplayName</td>
</tr>
<tr>
<td>First Name</td>
<td>@Model.GivenName</td>
</tr>
<tr>
<td>Last Name</td>
<td>@Model.Surname</td>
</tr>
<tr>
<td>Employee Id</td>
<td>@Model.extension_ExtId_ExtName</td>
</tr>
</table>
@if (ViewBag.ErrorMessage == "AuthorizationRequired")
{
<p>You have to sign-in to see your profile. Click @Html.ActionLink("here", "Index", "UserProfile", new { reauth = true }, null) to sign-in.</p>
}
@if (ViewBag.ErrorMessage == "UnexpectedError")
{
<p>An unexpected error occurred while retrieving your profile. Please try again. You may need to sign-in.</p>
}
我的目标是让扩展 extension_ExtId_ExtName
出现在用户列表中。我正在尝试使用解决方案的 UsersController
和视图来获取此信息,但似乎无法修改 Microsoft Graph API 用户模型。该模型设置为 Microsoft Graph 客户端控制的 IEnumerable<User>
。
如何添加我的自定义扩展以便我也可以从用户对象中检索它?
我已经确认我可以通过用户对象获取它,方法是转到 Graph Explorer 并将我的请求 URL 设置为:
https://graph.microsoft.com/beta/users('{user@email.com}')?select=extension_EXTENSION-ID_extensionName
谢谢
我认为这里的部分问题是您将两个不同的 API 混为一谈。还有就是Microsoft Graph API and the Azure Active Directory Graph API;这是两个完全不同的 API。虽然它们之间有很多功能重叠,但它们之间的调用不可互换。
我建议改为查看这些 Microsoft Graph API 示例: