Microsoft Entra ロールをグループに割り当てる

ロール管理を簡略化するために、Microsoft Entra ロールを個人ではなくグループに割り当てることができます。 この記事では、Microsoft Entra 管理センター、PowerShell、または Microsoft Graph API を使用して、ロールを割り当て可能なグループに Microsoft Entra ロールを割り当てる方法について説明します。

前提条件

詳細については、PowerShell または Graph エクスプローラーを使用するための前提条件に関するページを参照してください。

Microsoft Entra 管理センター

ヒント

この記事の手順は、開始するポータルに応じて若干異なる場合があります。

グループへの Microsoft Entra ロールの割り当ては、ユーザーとサービス プリンシパルの割り当てに似ていますが、使用できるのはロールを割り当て可能なグループのみという点が異なります。

ヒント

これらの手順は、Microsoft Entra ID P1 ライセンスをお持ちのお客様に適用されます。 テナントに Microsoft Entra ID P2 ライセンスがある場合は、「Privileged Identity Management で Microsoft Entra ロールを割り当てる」の手順に従う必要があります。

  1. Microsoft Entra 管理センター特権ロール管理者以上としてサインインします。

  2. [Identity] (ID)>[役割と管理者]>[役割と管理者] の順に移動します。

    Microsoft Entra ID の「ロールと管理者」ページのスクリーンショット。

  3. ロール名を選択してロールを開きます。 ロールの横にチェック マークを付けないでください。

    ロールの選択を示すスクリーンショット。

  4. [割り当ての追加] を選択します。

    次のスクリーンショットと異なる内容が表示された場合は、Microsoft Entra ID P2 をお持ちの可能性があります。 詳細については、「Privileged Identity Management で Microsoft Entra ロールを割り当てる」を参照してください。

    ユーザーまたはグループにロールを割り当てる [割り当ての追加] ウィンドウのスクリーンショット。

  5. このロールを割り当てるグループを選択します。 ロールを割り当て可能なグループのみが表示されます。

    グループが一覧にない場合は、ロールを割り当て可能なグループを作成する必要があります。 詳細については、「Microsoft Entra ID でロールを割り当て可能なグループを作成する」を参照してください。

  6. [追加] を選択して、グループにロールを割り当てます。

PowerShell

ロールを割り当て可能なグループを作成する

New-MgGroup コマンドを使用して、ロールを割り当て可能なグループを作成します。

Connect-MgGraph -Scopes "Group.ReadWrite.All","RoleManagement.ReadWrite.Directory"
$group = New-MgGroup -DisplayName "Contoso_Helpdesk_Administrators" -Description "This group has Helpdesk Administrator built-in role assigned to it in Azure AD." -MailEnabled:$false -SecurityEnabled -MailNickName "contosohelpdeskadministrators" -IsAssignableToRole:$true

割り当てるロールの定義を取得する

Get-MgRoleManagementDirectoryRoleDefinition コマンドを使用して、ロールの定義を取得します。

$roleDefinition = Get-MgRoleManagementDirectoryRoleDefinition -Filter "displayName eq 'Helpdesk Administrator'"

ロールの割り当てを作成する

New-MgRoleManagementDirectoryRoleAssignment コマンドを使用して、ロールを割り当てます。

$roleAssignment = New-MgRoleManagementDirectoryRoleAssignment -DirectoryScopeId '/' -RoleDefinitionId $roleDefinition.Id -PrincipalId $group.Id

Microsoft Graph API

ロールを割り当て可能なグループを作成する

グループの作成 API を使用して、ロールを割り当て可能なグループを作成します。

Request

POST https://graph.microsoft.com/v1.0/groups

{
    "description": "This group is assigned to Helpdesk Administrator built-in role of Azure AD.",
    "displayName": "Contoso_Helpdesk_Administrators",
    "groupTypes": [
        "Unified"
    ],
    "isAssignableToRole": true,
    "mailEnabled": true,
    "mailNickname": "contosohelpdeskadministrators",
    "securityEnabled": true
}

Response

HTTP/1.1 201 Created

割り当てるロールの定義を取得する

List unifiedRoleDefinitions API を使用してロールの定義を取得します。

Request

GET https://graph.microsoft.com/v1.0/roleManagement/directory/roleDefinitions?$filter = displayName eq 'Helpdesk Administrator'

Response

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#roleManagement/directory/roleDefinitions",
    "value": [
        {
            "id": "729827e3-9c14-49f7-bb1b-9608f156bbb8",
            "description": "Can reset passwords for non-administrators and Helpdesk Administrators.",
            "displayName": "Helpdesk Administrator",
            "isBuiltIn": true,
            "isEnabled": true,
            "resourceScopes": [
                "/"
            ],

    ...

ロールの割り当てを作成する

Create unifiedRoleAssignment API を使用してロールを割り当てます。

Request

POST https://graph.microsoft.com/v1.0/roleManagement/directory/roleAssignments

{
    "@odata.type": "#microsoft.graph.unifiedRoleAssignment",
    "principalId": "<Object ID of Group>",
    "roleDefinitionId": "<ID of role definition>",
    "directoryScopeId": "/"
}

Response

HTTP/1.1 201 Created
Content-type: application/json
{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#roleManagement/directory/roleAssignments/$entity",
    "id": "<Role assignment ID>",
    "roleDefinitionId": "<ID of role definition>",
    "principalId": "<Object ID of Group>",
    "directoryScopeId": "/"
}

次のステップ