【发布时间】:2015-01-25 10:34:34
【问题描述】:
我正在使用 GraphHelper 库 (http://www.nuget.org/packages/Microsoft.Azure.ActiveDirectory.GraphClient) 从 Azure AD 获取用户详细信息。但是,我正在努力获取 approles 信息,它返回:
资源“appRoleAssignments”不存在或其查询的引用属性对象之一不存在。
代码:
public static async Task<List<AzureAppRole>> GetApplications(User user)
{
var appRoles = new List<AzureAppRole>();
var userFetcher = user as IUserFetcher;
IPagedCollection<IAppRoleAssignment> rawObjects = await userFetcher.AppRoleAssignments.ExecuteAsync();
do
{
List<IAppRoleAssignment> directoryObjects = rawObjects.CurrentPage.ToList();
foreach (IAppRoleAssignment dobject in directoryObjects)
{
if (dobject is AppRole)
{
var u = (AppRole)dobject;
appRoles.Add(new AzureAppRole
{
DisplayName = u.DisplayName,
ObjectId = u.Value
});
}
}
rawObjects = rawObjects.GetNextPageAsync().Result;
} while (rawObjects != null && rawObjects.MorePagesAvailable);
return appRoles;
}
编辑:
查看原始 API 调用,我可以看到它正在调用以下内容,当使用 GraphExplorer 进行查询时会导致错误:
https://graph.windows.net/tenant/directoryObjects/objectid/appRoleAssignments?api-version=1.5
但是,以下查询会导致返回结果:
https://graph.windows.net/tenant/users/objectid/appRoleAssignments?api-version=1.5
这是库中的错误吗?
【问题讨论】:
-
在 2.0.5 版本中修复。
标签: api azure office365 azure-active-directory