Azure - 在 PIM 中分配网络贡献者

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

我想通过 powershell 使 Azure 角色(网络贡献者)在特定范围(实际上是租户根组)下符合 PIM 资格。

我可以使用以下方法将正常的内部角色(全局管理员)分配为符合条件: 新 MgRoleManagementDirectoryRoleEligibilityScheduleRequest

但是 Azure 角色的等价物是什么?

我尝试过 New-MgRoleManagementDirectoryRoleEligibilityScheduleRequest 和 New-AzRoleAssignment (但无法让它工作)

azure azure-active-directory
1个回答
0
投票

最初,我创建了安全组

TestPIMRole
并向其中添加了两名成员:

enter image description here

之后,我注册了 Microsoft Entra 应用程序,并为其分配了

Owner
的特权管理员角色(服务主体),并授予了 API 权限
user_impersonation
Azure Service Management
如下所示:

enter image description here

现在,我使用

client_credentials
流程生成了访问令牌:

POST https://login.microsoftonline.com/<tenant_id>/oauth2/v2.0/token

client_id = <client_id>
client_secret= <client secret>
grant_type = client_credentials
scope = https://management.azure.com/.default

enter image description here

生成访问令牌后,请确保在 https://jwt.ms 处解码 jwt 令牌后,

jwt
令牌必须具有
"aud": "https://management.azure.com"

使用生成的访问令牌

Authorization:Auth Type: Bearer Token

enter image description here

使用下面的代码片段成功分配 Azure 内置角色,其中

Eligible Assignment
Network Contributor 
角色:

PUT https://management.azure.com/providers/Microsoft.Subscription/subscriptions/<subscription_id>/providers/Microsoft.Authorization/roleEligibilityScheduleRequests/a196c57e-ef93-450f-947f-a5148701d8c4?api-version=2020-10-01-preview

Body: raw 

{
  "properties": {
    "principalId": "c2bb2114-edd2-4704-998b-da6ba635fc8c",
    "roleDefinitionId": "/subscriptions/<subscription_id>/providers/Microsoft.Authorization/roleDefinitions/4d97b98b-1d4f-4787-a291-c67834d212e7",
    "requestType": "AdminAssign",
    "scheduleInfo": {
      "startDateTime": "2024-07-02T21:00:00.91Z",
      "expiration": {
        "type": "AfterDuration",
        "endDateTime": null,
        "duration": "P365D"
      }
    }
     }
}

Azure 资源的 Azure Privileged Identity Management (PIM) 中网络贡献者角色的合格分配基于

startDateTime
(采用 UTC 格式)反映。

输出:

enter image description here

enter image description here

参考:

在 Privileged Identity Management 中分配 Azure 资源角色

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