Microsoft图形过滤器分配的角色

时间:2018-11-05 13:00:39

标签: azure-active-directory microsoft-graph

在Azure Active Directory中,我创建了一个应用,在清单文件中,我用以下值更新了appRoles

  "appRoles": [
{
  "allowedMemberTypes": [
    "User"
  ],
  "displayName": "Client manager",
  "id": "bf77e391-0bbf-4e33-854b-a384a5ac0630",
  "isEnabled": true,
  "description": "Client manager can manage all client actions.",
  "value": "ClientManager"
}]

我更新了用户,以使分配的角色不再是Default Access,而是Client manager

使用Graph API,我正在尝试检索此分配的角色。 我尝试了此uri,但由于某种原因,它不会返回我的角色。 https://graph.microsoft.com/beta/me/appRoleAssignments?$filter=resourceId eq 04dcaab1-7219-4689-8510-4672e957ac11$select=appRoleId 但是响应是:

{
"error": {
    "code": "BadRequest",
    "message": "Invalid filter clause",
    "innerError": {
        "request-id": "ce3cb456-956b-41c5-84a2-cdcdfe1ac3c5",
        "date": "2018-11-05T20:54:08"
    }
}

}

我可以为所有应用程序创建一个要求所有角色的解决方法,但这是我要避免的事情。这将以以下uri结尾: https://graph.microsoft.com/beta/me/appRoleAssignments?$select=resourceId,appRoleId

并生成此json,我需要在其中过滤出我的applicationid。

{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#appRoleAssignments(resourceId,appRoleId)",
"value": [
    {
        "appRoleId": "00000000-0000-0000-0000-000000000000",
        "resourceId": "667cc3aa-00b9-4526-bde5-b81312ed5afb"
    },
    {
        "appRoleId": "00000000-0000-0000-0000-000000000000",
        "resourceId": "64b92ac1-4a56-478c-8774-5c584fb200e5"
    },
    {
        "appRoleId": "bf77e391-0bbf-4e33-854b-a384a5ac0630",
        "resourceId": "04dcaab1-7219-4689-8510-4672e957ac11"
    }
]

}

我已经尝试了在StackOverflow上提出的几种解决方案,但是由于某种原因,所有eq过滤器均无法使用。我正在用Graph explorer测试查询。我想要的结果应该是这样的:

{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#appRoleAssignments(appRoleId)",
"value": [
    {
        "appRoleId": "bf77e391-0bbf-4e33-854b-a384a5ac0630"
    }
]

}

1 个答案:

答案 0 :(得分:1)

似乎不支持用resourceId过滤https://graph.microsoft.com/beta/me/appRoleAssignments

doc中所述:

  

并非所有Microsoft Graph API都支持所有参数,并且v1.0beta端点之间的支持可能会有很大差异。

此外,如果我们用id过滤GET https://graph.microsoft.com/beta/me/appRoleAssignments?$filter=id eq 'xxxxxxx',它将正常工作。因此,我认为查询的格式应该正确,唯一的可能性就是不支持该文档中提到的格式。

enter image description here

相关问题