Azure RBAC Rest API 调用以获取对象类型

Azure RBAC Rest API call to get Object Type

我正在使用此调用 https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments?api-version=2015-07-01 来获取订阅的角色分配。输出是这个给principalId和其他值

问题是如何区分 principalId 是用户主体还是服务主体?

这是我查询图 api 以获取 appid(如果是服务原则)或显示名称、upn(如果是用户原则)所必需的。

图 APi 对此有 2 个不同的调用,因此在自动化时我需要根据对象类型知道要调用哪个。

用户:https://graph.windows.net/microsoft.com/users/principalid?api-version=1.6

服务价格:https://graph.windows.net/microsoft.com/servicePrincipals/principalid?api-version=1.6

Graph APi has 2 different call for this hence while automating I need to know which one to be called based on object type.

根据我的理解,您可以使用 Objects - Get Objects By Object Ids Rest API 通过 principleid 获取对象,无需调用 2 个不同的调用。您还可以从响应中获取对象类型。

POST https://graph.windows.net/{tenantID}/getObjectsByObjectIds?api-version=1.6

我测试了 2 个 principalids,一个是服务主体,另一个是用户。

测试结果: