Microsoft Graph API - 获取具有指定应用角色的用户

问题描述 投票:0回答:1

我有关于 Graph API 的问题。我需要下载“ApplicationA”中已分配应用程序角色“Role”的所有用户。我需要它来下载具有发送电子邮件所需的应用程序角色的所有用户。我尝试了各种方法,通过使用以下 API 的用户列表:

https://graph.microsoft.com/v1.0/users?$expand=appRoleAssignments&$count=true&$filter=appRoleAssignments/any(w:w/appRoleId eq {guid})

但是这会返回以下错误,我当然尝试过类似的选项。

{
    "error": {
        "code": "Request_UnsupportedQuery",
        "message": "Property 'appRoleId' does not exist as a declared property or extension property.",
        "innerError": {
            "date": "2024-02-28T20:49:49",
            "request-id": "bf8991a4-82e9-4136-9664-1cebc1718ae0",
            "client-request-id": "bf8991a4-82e9-4136-9664-1cebc1718ae0"
        }
    }
}

我也尝试过使用 servicePrincipals。但这会返回分配给服务主体的所有用户/应用程序,而不仅仅是我需要的角色,并且我尝试使用 OData 进行的过滤不起作用。下载了很多项目:

https://graph.microsoft.com/v1.0/servicePrincipals(appId='{guid}')/appRoleAssignedTo

您知道更好的解决方案吗?谢谢

c# .net microsoft-graph-api azure-ad-graph-api microsoft-entra-id
1个回答
0
投票

注意

appRoleAssignments
端点不支持对
appRoleId
进行过滤。请参阅 CarlZhao-MSFT 的 Microsoft QnA。因此,不可能获取具有指定应用程序角色的用户。

企业应用程序中分配的用户和组:

enter image description here

作为解决方法,您可以根据

resourceID
列出分配给用户和组的角色。

对于用户

https://graph.microsoft.com/v1.0/Users/UserID/appRoleAssignments?$filter=resourceId eq ServicePrincipalObjID

enter image description here

对于团体

https://graph.microsoft.com/v1.0/groups/GroupID/appRoleAssignments?$filter=resourceId eq ServicePrincipalObjID

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.