如何获取具有角色权限的用户

时间:2021-02-16 04:38:13

标签: azure microsoft-graph-api postman restapi azure-rest-api

我正在使用此 [订阅 api][https://management.azure.com/subscriptions?api-version=2020-01-01] 来获取 azure 订阅详细信息。但在响应中,我们获得的授权源基于角色。我们如何获取该订阅中存在的用户以及有哪些权限(前所有者、读者)

enter image description here

1 个答案:

答案 0 :(得分:1)

首先,您可以使用this API来获取您订阅的角色分配,如下所示: enter image description here

每个项目记录代表一个角色分配。您可以找到 roleDefinitionId 表示您分配的角色,principalId 表示分配给哪个 Azure AD 应用程序或用户的角色。

因此,如果您想获取有关角色信息的详细信息,则应偶尔调用以下 API:

GET https://management.azure.com/<value of roleDefinitionId>?api-version=2018-07-01

enter image description here

如果你想获得principalId的详细信息,你应该调用Microsoft Graph APIget directory object,如下所示:

enter image description here

如果您只想查询分配有订阅角色的用户/Azure 广告应用程序,这会容易得多,因为此 API 为我们提供了 $filter 参数,假设您有用户的对象 ID,您可以通过以下请求过滤此用户的角色:

enter image description here