azure-active-directory - 如何授予服务主体对 Active Directory 组的读取权限?

标签 azure-active-directory microsoft-graph-api github-actions active-directory-group azure-service-principal

目前,我正在尝试从我使用服务主体登录的 GitHub 操作读取 Active Directory 组的 ObjectId。

服务主体是具有以下附加权限的贡献者:

"Microsoft.Authorization/roleAssignments/write",
"Microsoft.Authorization/roleAssignments/read"

使用 Azure CLI 运行以下命令时:

az ad group show -g {NAME OF GROUP}

我收到以下输出:

ValidationError: Insufficient privileges to complete the operation.
Error: Error: az cli script failed.

我尝试通过 Microsoft Graph API 通过以下权限向服务主体授予权限:

Directory.Read.All (Granted)
Group.Read.All (Granted)

但是这些不足以授予读取权限。

最佳答案

解决问题的两种方法(推荐第一种):

  1. 此命令实质上调用的是 Azure AD Graph 而不是 Microsoft Graph,因此 Microsoft Graph 的权限不会生效,这里您需要的是 Application权限(不是委托(delegate)权限)Azure AD Graph 中的Directory.Read.All

enter image description here

enter image description here

enter image description here

  • 另一种方法是给出 Azure AD admin role给服务主体,例如Directory Readers ,该角色的权限小于上面的Directory.Read.All,并且AAD Graph是Supported Legacy API,所以推荐第二种方式。赋予角色后,等待一段时间生效即可正常使用。
  • enter image description here

    enter image description here

    关于azure-active-directory - 如何授予服务主体对 Active Directory 组的读取权限?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65429219/

    相关文章:

    node.js - 如何将多个 Azure Active Directory 帐户连接到您的应用程序?

    ios - 具有 Swift 包管理器依赖项的项目的 Github 操作

    json - 在 Github Actions 中读取 JSON 文件

    amazon-web-services - 部署到 AWS S3 与 github 同步

    javascript - 使用 SPA 对 Microsoft Graph 进行身份验证,然后在 Web API 中使用 token

    azure - 如何将 JSON 对象数组作为自定义策略中的输入声明传递给 REST API

    Azure v2.0刷新 token ,返回另一个刷新 token

    azure - Keda AzureMonitor 触发器没有给出 activeDirectoryClientId 错误

    oauth-2.0 - Azure AD B2C 错误 : The client Id specified in the request is not registered in tenant

    c# - 使用 Graph 创建团队后是否需要等待