简体   繁体   English

使用 Azure Resource Graph 获取其他用户的资源

[英]Using Azure Resource Graph to get other user's Resources

I am trying to query with an app ID all the resources a user has.我正在尝试使用应用程序 ID 查询用户拥有的所有资源。 My current implementation is to get all the resources my app has access to, and then query the RBAC of each one of those resources to see if the user has access.我当前的实现是获取我的应用程序有权访问的所有资源,然后查询每个资源的 RBAC 以查看用户是否有权访问。 It seems to be way too many calls for something it can be done for my current user using Azure Resource Graph.使用 Azure Resource Graph 为我当前的用户可以完成的事情似乎太多了。 Is there a way to use Azure Resource Graph but specify which user I want to get the resources for (assuming my app has reader access to all resources in the tenant)?有没有办法使用 Azure Resource Graph 但指定我想要为其获取资源的用户(假设我的应用程序具有对租户中所有资源的读者访问权限)?

From your description, want you need to find is the role assignments in your subscription, its resource type is Microsoft.Authorization/roleAssignments , which is not included in the Azure Resource Graph.从您的描述中,您需要查找的是订阅中的角色分配,其资源类型为Microsoft.Authorization/roleAssignments ,未包含在 Azure 资源图中。

Your option is to use the REST API - Role Assignments - List , filter with the ObjectId of the user in Azure AD.您可以选择使用 REST API - Role Assignments - List ,并使用 Azure AD 中用户的ObjectId进行筛选。 To get the access token to call the REST API with the AD App(the AppId you mentioned), you need to use the client credential flow, refer to this link .要获取访问令牌以使用 AD App(您提到的 AppId)调用 REST API,您需要使用客户端凭据流,请参阅此链接

Sample :样品

Check the scope in the response, they are the resources the user can access.检查响应中的scope ,它们是用户可以访问的资源。

GET https://management.azure.com/subscriptions/<subscription-id>/providers/Microsoft.Authorization/roleAssignments?$filter=principalId eq '<object-id>'&api-version=2018-09-01-preview 

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 通过 Azure 资源图查询获取 Azure 与某个 su.net 关联的资源 - Get Azure resources associated with a subnet through Azure Resource Graph Query Azure使用Azure资源图计算VMSS中的所有VM - Azure count all VM's in VMSS using Azure Resource Graph 如何使用 azure 资源图获取 Azure VM 最后一次重启 - how to get Azure VM last reboot using azure resource graph 如何使用 Azure 资源管理 api 按资源类型和资源组获取资源列表 - How to get List of resources by resource type and resource group by using Azure Resource management apis 使用资源管理器以天蓝色获取具有关系的资源 - Fetch resources with relationship in azure using resource manager 如何将 Azure 资源委派给任何其他用户? - How to delegate Azure resources to any other user? 如何获取其他 Azure Active Directory 组织的列表 - How can I get a list of other Azure Active Directory organizations I'm a Guest User of using an API eg, Graph Azure资源管理器 - 获取资源组的所有资源 - Azure Resource Manager - Get all the resources of a resource group Azure虚拟网络网关-访问其他资源组中的资源 - Azure Virtual Network Gateway - Access resources in other resource groups 如何获取 Azure 资源组中没有标记的所有 Azure 资源 - How to get all Azure Resources without tags in a Azure Resource Group
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM