名前空間: microsoft.graph
重要
Microsoft Graph の /beta バージョンの API は変更される可能性があります。 実稼働アプリケーションでこれらの API を使用することは、サポートされていません。 v1.0 で API を使用できるかどうかを確認するには、Version セレクターを使用します。
新しい unifiedRoleAssignmentScheduleRequest オブジェクトを 作成します。 この操作を使用すると、管理者とユーザーの両方が割り当てを追加、削除、延長、または更新できます。 この要求を実行するには、呼び出し元のユーザーに多要素認証 (MFA) が適用され、MFA に対してチャレンジされたセッションでクエリを実行する必要があります。
「ユーザーごとのMicrosoft Entra多要素認証を有効にしてサインイン イベントをセキュリティで保護する」を参照してください。
この API は、次の国内クラウド展開で使用できます。
| グローバル サービス |
米国政府機関 L4 |
米国政府機関 L5 (DOD) |
21Vianet が運営する中国 |
| ✅ |
✅ |
✅ |
✅ |
アクセス許可
この API の最小特権としてマークされているアクセス許可またはアクセス許可を選択します。
アプリで必要な場合にのみ、より高い特権のアクセス許可またはアクセス許可を使用します。 委任されたアクセス許可とアプリケーションのアクセス許可の詳細については、「アクセス許可の種類」を参照してください。 これらのアクセス許可の詳細については、「アクセス許可のリファレンス」を参照してください。
| アクセス許可の種類 |
最小特権アクセス許可 |
より高い特権のアクセス許可 |
| 委任 (職場または学校のアカウント) |
RoleAssignmentSchedule.ReadWrite.Directory |
RoleAssignmentSchedule.Remove.Directory、RoleEligibilitySchedule.Remove.Directory、RoleManagement.ReadWrite.Directory |
| 委任 (個人用 Microsoft アカウント) |
サポートされていません。 |
サポートされていません。 |
| アプリケーション |
RoleAssignmentSchedule.ReadWrite.Directory |
RoleManagement.ReadWrite.Directory、RoleAssignmentSchedule.Remove.Directory、RoleEligibilitySchedule.Remove.Directory |
重要
職場または学校アカウントを使用した委任されたシナリオでは、サインインしているユーザーに、サポートされているMicrosoft Entraロールまたはサポートされているロールのアクセス許可を持つカスタム ロールを割り当てる必要があります。 この操作では、次の最小特権ロールがサポートされています。
- 読み取り操作の場合: グローバル 閲覧者、セキュリティ オペレーター、セキュリティ閲覧者、セキュリティ管理者、または特権ロール管理者
- 書き込み操作の場合: 特権ロール管理者
HTTP 要求
POST /roleManagement/directory/roleAssignmentScheduleRequests
| 名前 |
説明 |
| Authorization |
ベアラー {token}。 必須です。
認証と認可についての詳細をご覧ください。 |
| Content-Type |
application/json. 必須です。 |
要求本文
要求本文で、 unifiedRoleAssignmentScheduleRequest オブジェクトの JSON 表現を指定します。
次の表に、 unifiedRoleAssignmentScheduleRequest を作成するときに必要なプロパティを示します。
| プロパティ |
型 |
説明 |
| id |
文字列 |
unifiedRoleAssignmentScheduleRequest の一意識別子。 キー。null 許容ではなく、読み取り専用です。 |
| action |
文字列 |
ロールの割り当てに対する操作の種類を表します。 値は次のいずれかです。-
AdminAssign: 管理者がユーザーまたはグループにロールを割り当てる場合。 -
AdminRemove: 管理者がロールからユーザーまたはグループを削除する場合。 -
AdminUpdate: 管理者が既存のロールの割り当てを変更する場合。 -
AdminExtend: 管理者が期限切れの割り当てを延長する場合。 -
AdminRenew: 管理者が期限切れの割り当てを更新する場合。 -
SelfActivate: ユーザーが自分の割り当てをアクティブ化します。 -
SelfDeactivate: ユーザーがアクティブな割り当てを非アクティブ化する。 -
SelfExtend: ユーザーが期限切れの割り当ての延長を要求する。 -
SelfRenew: ユーザーが期限切れの割り当ての更新を要求する。
|
| principalId |
文字列 |
割り当てが付与されているプリンシパルの識別子。 |
| roleDefinitionId |
文字列 |
割り当てが対象の unifiedRoleDefinition の識別子。 読み取り専用です。 |
| directoryScopeId |
String |
割り当てのスコープを表すディレクトリ オブジェクトの識別子。 割り当てのスコープによって、プリンシパルにアクセス権が付与されているリソースのセットが決まります。 ディレクトリ スコープは、複数のアプリケーションによって認識されるディレクトリに格納されている共有スコープです。 テナント全体のスコープには / を使用します。
appScopeId を使用して、スコープをアプリケーションのみに制限します。 |
| appScopeId |
文字列 |
割り当てスコープがアプリ固有の場合のアプリ固有のスコープの識別子。 割り当てのスコープによって、プリンシパルにアクセス権が付与されているリソースのセットが決まります。 アプリ スコープは、このアプリケーションによってのみ定義および理解されるスコープです。 テナント全体のアプリ スコープに / を使用します。
directoryScopeId を使用して、スコープを特定のディレクトリ オブジェクト (管理単位など) に制限します。 |
| isValidationOnly |
ブール値 |
呼び出しが検証呼び出しか実際の呼び出しかを指定します。 アクティブ化が MFA などの追加ルールの対象であるかどうかを実際に要求を送信する前にチェックする場合にのみ、このプロパティを設定します。 |
| targetScheduleId |
文字列 |
割り当てにアタッチされた schedule オブジェクトの ID。 |
| ジャスティフィケーション |
文字列 |
要求を作成するときに、ユーザーと管理者から、必要な理由に関するメッセージが表示されます。 |
| scheduleInfo |
requestSchedule |
ロール割り当て要求の schedule オブジェクト。 |
| ticketInfo |
ticketInfo |
チケット番号とチケット システムの詳細を含む、ロール割り当て要求にアタッチされている ticketInfo オブジェクト。 |
応答
成功した場合、このメソッドは 201 Created 応答コードと、応答本文の unifiedRoleAssignmentScheduleRequest オブジェクトを返します。
呼び出し元のユーザーがサインイン セッション中に多要素認証に対してチャレンジされなかった場合、SelfActivate アクションを使用した要求は失敗し、 400 Bad request 応答コードが返されます。
例
例 1: ディレクトリ ロールをプリンシパルに割り当てる管理
要求
次の要求では、管理者は id07706ff1-46c7-4847-ae33-3003830675a1 で識別されるプリンシパルにfdd7a751-b60b-444a-984c-02652fe8fa1cによって識別されるロールを割り当てる要求を作成します。ロールのスコープはテナント内のすべてのディレクトリ オブジェクトであり、割り当ては永続的です。つまり、期限切れにはなりません。
POST https://graph.microsoft.com/beta/roleManagement/directory/roleAssignmentScheduleRequests/
Content-Type: application/json
{
"action": "AdminAssign",
"justification": "Assign User Admin to IT Helpdesk (User) group",
"roleDefinitionId": "fdd7a751-b60b-444a-984c-02652fe8fa1c",
"directoryScopeId": "/",
"principalId": "07706ff1-46c7-4847-ae33-3003830675a1",
"scheduleInfo": {
"startDateTime": "2021-07-01T00:00:00Z",
"expiration": {
"type": "NoExpiration"
}
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new UnifiedRoleAssignmentScheduleRequest
{
Action = "AdminAssign",
Justification = "Assign User Admin to IT Helpdesk (User) group",
RoleDefinitionId = "fdd7a751-b60b-444a-984c-02652fe8fa1c",
DirectoryScopeId = "/",
PrincipalId = "07706ff1-46c7-4847-ae33-3003830675a1",
ScheduleInfo = new RequestSchedule
{
StartDateTime = DateTimeOffset.Parse("2021-07-01T00:00:00Z"),
Expiration = new ExpirationPattern
{
Type = ExpirationPatternType.NoExpiration,
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.RoleManagement.Directory.RoleAssignmentScheduleRequests.PostAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewUnifiedRoleAssignmentScheduleRequest()
action := "AdminAssign"
requestBody.SetAction(&action)
justification := "Assign User Admin to IT Helpdesk (User) group"
requestBody.SetJustification(&justification)
roleDefinitionId := "fdd7a751-b60b-444a-984c-02652fe8fa1c"
requestBody.SetRoleDefinitionId(&roleDefinitionId)
directoryScopeId := "/"
requestBody.SetDirectoryScopeId(&directoryScopeId)
principalId := "07706ff1-46c7-4847-ae33-3003830675a1"
requestBody.SetPrincipalId(&principalId)
scheduleInfo := graphmodels.NewRequestSchedule()
startDateTime , err := time.Parse(time.RFC3339, "2021-07-01T00:00:00Z")
scheduleInfo.SetStartDateTime(&startDateTime)
expiration := graphmodels.NewExpirationPattern()
type := graphmodels.NOEXPIRATION_EXPIRATIONPATTERNTYPE
expiration.SetType(&type)
scheduleInfo.SetExpiration(expiration)
requestBody.SetScheduleInfo(scheduleInfo)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
roleAssignmentScheduleRequests, err := graphClient.RoleManagement().Directory().RoleAssignmentScheduleRequests().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
UnifiedRoleAssignmentScheduleRequest unifiedRoleAssignmentScheduleRequest = new UnifiedRoleAssignmentScheduleRequest();
unifiedRoleAssignmentScheduleRequest.setAction("AdminAssign");
unifiedRoleAssignmentScheduleRequest.setJustification("Assign User Admin to IT Helpdesk (User) group");
unifiedRoleAssignmentScheduleRequest.setRoleDefinitionId("fdd7a751-b60b-444a-984c-02652fe8fa1c");
unifiedRoleAssignmentScheduleRequest.setDirectoryScopeId("/");
unifiedRoleAssignmentScheduleRequest.setPrincipalId("07706ff1-46c7-4847-ae33-3003830675a1");
RequestSchedule scheduleInfo = new RequestSchedule();
OffsetDateTime startDateTime = OffsetDateTime.parse("2021-07-01T00:00:00Z");
scheduleInfo.setStartDateTime(startDateTime);
ExpirationPattern expiration = new ExpirationPattern();
expiration.setType(ExpirationPatternType.NoExpiration);
scheduleInfo.setExpiration(expiration);
unifiedRoleAssignmentScheduleRequest.setScheduleInfo(scheduleInfo);
UnifiedRoleAssignmentScheduleRequest result = graphClient.roleManagement().directory().roleAssignmentScheduleRequests().post(unifiedRoleAssignmentScheduleRequest);
const options = {
authProvider,
};
const client = Client.init(options);
const unifiedRoleAssignmentScheduleRequest = {
action: 'AdminAssign',
justification: 'Assign User Admin to IT Helpdesk (User) group',
roleDefinitionId: 'fdd7a751-b60b-444a-984c-02652fe8fa1c',
directoryScopeId: '/',
principalId: '07706ff1-46c7-4847-ae33-3003830675a1',
scheduleInfo: {
startDateTime: '2021-07-01T00:00:00Z',
expiration: {
type: 'NoExpiration'
}
}
};
await client.api('/roleManagement/directory/roleAssignmentScheduleRequests/')
.version('beta')
.post(unifiedRoleAssignmentScheduleRequest);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\UnifiedRoleAssignmentScheduleRequest;
use Microsoft\Graph\Beta\Generated\Models\RequestSchedule;
use Microsoft\Graph\Beta\Generated\Models\ExpirationPattern;
use Microsoft\Graph\Beta\Generated\Models\ExpirationPatternType;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new UnifiedRoleAssignmentScheduleRequest();
$requestBody->setAction('AdminAssign');
$requestBody->setJustification('Assign User Admin to IT Helpdesk (User) group');
$requestBody->setRoleDefinitionId('fdd7a751-b60b-444a-984c-02652fe8fa1c');
$requestBody->setDirectoryScopeId('/');
$requestBody->setPrincipalId('07706ff1-46c7-4847-ae33-3003830675a1');
$scheduleInfo = new RequestSchedule();
$scheduleInfo->setStartDateTime(new \DateTime('2021-07-01T00:00:00Z'));
$scheduleInfoExpiration = new ExpirationPattern();
$scheduleInfoExpiration->setType(new ExpirationPatternType('noExpiration'));
$scheduleInfo->setExpiration($scheduleInfoExpiration);
$requestBody->setScheduleInfo($scheduleInfo);
$result = $graphServiceClient->roleManagement()->directory()->roleAssignmentScheduleRequests()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Identity.Governance
$params = @{
action = "AdminAssign"
justification = "Assign User Admin to IT Helpdesk (User) group"
roleDefinitionId = "fdd7a751-b60b-444a-984c-02652fe8fa1c"
directoryScopeId = "/"
principalId = "07706ff1-46c7-4847-ae33-3003830675a1"
scheduleInfo = @{
startDateTime = [System.DateTime]::Parse("2021-07-01T00:00:00Z")
expiration = @{
type = "NoExpiration"
}
}
}
New-MgBetaRoleManagementDirectoryRoleAssignmentScheduleRequest -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.unified_role_assignment_schedule_request import UnifiedRoleAssignmentScheduleRequest
from msgraph_beta.generated.models.request_schedule import RequestSchedule
from msgraph_beta.generated.models.expiration_pattern import ExpirationPattern
from msgraph_beta.generated.models.expiration_pattern_type import ExpirationPatternType
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = UnifiedRoleAssignmentScheduleRequest(
action = "AdminAssign",
justification = "Assign User Admin to IT Helpdesk (User) group",
role_definition_id = "fdd7a751-b60b-444a-984c-02652fe8fa1c",
directory_scope_id = "/",
principal_id = "07706ff1-46c7-4847-ae33-3003830675a1",
schedule_info = RequestSchedule(
start_date_time = "2021-07-01T00:00:00Z",
expiration = ExpirationPattern(
type = ExpirationPatternType.NoExpiration,
),
),
)
result = await graph_client.role_management.directory.role_assignment_schedule_requests.post(request_body)
応答
次の例は応答を示しています。
注: ここに示す応答オブジェクトは、読みやすさのために短縮されている場合があります。
HTTP/1.1 201 Created
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#roleManagement/directory/roleAssignmentScheduleRequests/$entity",
"id": "b5a22921-656a-4429-9c4e-59a5f576614d",
"status": "Provisioned",
"createdDateTime": "2021-07-27T09:18:40.2029365Z",
"completedDateTime": "2021-07-27T09:18:42.7811184Z",
"approvalId": null,
"customData": null,
"action": "AdminAssign",
"principalId": "07706ff1-46c7-4847-ae33-3003830675a1",
"roleDefinitionId": "fdd7a751-b60b-444a-984c-02652fe8fa1c",
"directoryScopeId": "/",
"appScopeId": null,
"isValidationOnly": false,
"targetScheduleId": "b5a22921-656a-4429-9c4e-59a5f576614d",
"justification": "Assign User Admin to IT Helpdesk (User) group",
"createdBy": {
"application": null,
"device": null,
"user": {
"displayName": null,
"id": "fc9a2c2b-1ddc-486d-a211-5fe8ca77fa1f"
}
},
"scheduleInfo": {
"startDateTime": "2021-07-27T09:18:42.7811184Z",
"recurrence": null,
"expiration": {
"type": "noExpiration",
"endDateTime": null,
"duration": null
}
},
"ticketInfo": {
"ticketNumber": null,
"ticketSystem": null
}
}
例 2: 資格のあるロールをアクティブ化するユーザー
要求
次の要求では、 principalIdc6ad1942-4afa-47f8-8d48-afb5d8d69d2f によって識別されたユーザーが、 9b895d92-2cd3-44c7-9d02-a6ac2d5ea5c3によって識別される独自の適格なロールをアクティブ化します。 ロールのスコープはテナント内のすべてのディレクトリ オブジェクトであり、割り当ては 5 時間です。 この要求を実行するには、呼び出し元のユーザーに多要素認証 (MFA) が適用され、MFA に対してチャレンジされたセッションでクエリを実行する必要があります。
POST https://graph.microsoft.com/beta/roleManagement/directory/roleAssignmentScheduleRequests/
Content-Type: application/json
{
"action": "SelfActivate",
"principalId": "c6ad1942-4afa-47f8-8d48-afb5d8d69d2f",
"roleDefinitionId": "9b895d92-2cd3-44c7-9d02-a6ac2d5ea5c3",
"directoryScopeId": "/",
"justification": "Need to update app roles for selected apps.",
"scheduleInfo": {
"startDateTime": "2021-08-17T17:40:00.000Z",
"expiration": {
"type": "AfterDuration",
"duration": "PT5H"
}
},
"ticketInfo": {
"ticketNumber": "CONTOSO:Normal-67890",
"ticketSystem": "MS Project"
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new UnifiedRoleAssignmentScheduleRequest
{
Action = "SelfActivate",
PrincipalId = "c6ad1942-4afa-47f8-8d48-afb5d8d69d2f",
RoleDefinitionId = "9b895d92-2cd3-44c7-9d02-a6ac2d5ea5c3",
DirectoryScopeId = "/",
Justification = "Need to update app roles for selected apps.",
ScheduleInfo = new RequestSchedule
{
StartDateTime = DateTimeOffset.Parse("2021-08-17T17:40:00.000Z"),
Expiration = new ExpirationPattern
{
Type = ExpirationPatternType.AfterDuration,
Duration = TimeSpan.Parse("PT5H"),
},
},
TicketInfo = new TicketInfo
{
TicketNumber = "CONTOSO:Normal-67890",
TicketSystem = "MS Project",
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.RoleManagement.Directory.RoleAssignmentScheduleRequests.PostAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewUnifiedRoleAssignmentScheduleRequest()
action := "SelfActivate"
requestBody.SetAction(&action)
principalId := "c6ad1942-4afa-47f8-8d48-afb5d8d69d2f"
requestBody.SetPrincipalId(&principalId)
roleDefinitionId := "9b895d92-2cd3-44c7-9d02-a6ac2d5ea5c3"
requestBody.SetRoleDefinitionId(&roleDefinitionId)
directoryScopeId := "/"
requestBody.SetDirectoryScopeId(&directoryScopeId)
justification := "Need to update app roles for selected apps."
requestBody.SetJustification(&justification)
scheduleInfo := graphmodels.NewRequestSchedule()
startDateTime , err := time.Parse(time.RFC3339, "2021-08-17T17:40:00.000Z")
scheduleInfo.SetStartDateTime(&startDateTime)
expiration := graphmodels.NewExpirationPattern()
type := graphmodels.AFTERDURATION_EXPIRATIONPATTERNTYPE
expiration.SetType(&type)
duration , err := abstractions.ParseISODuration("PT5H")
expiration.SetDuration(&duration)
scheduleInfo.SetExpiration(expiration)
requestBody.SetScheduleInfo(scheduleInfo)
ticketInfo := graphmodels.NewTicketInfo()
ticketNumber := "CONTOSO:Normal-67890"
ticketInfo.SetTicketNumber(&ticketNumber)
ticketSystem := "MS Project"
ticketInfo.SetTicketSystem(&ticketSystem)
requestBody.SetTicketInfo(ticketInfo)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
roleAssignmentScheduleRequests, err := graphClient.RoleManagement().Directory().RoleAssignmentScheduleRequests().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
UnifiedRoleAssignmentScheduleRequest unifiedRoleAssignmentScheduleRequest = new UnifiedRoleAssignmentScheduleRequest();
unifiedRoleAssignmentScheduleRequest.setAction("SelfActivate");
unifiedRoleAssignmentScheduleRequest.setPrincipalId("c6ad1942-4afa-47f8-8d48-afb5d8d69d2f");
unifiedRoleAssignmentScheduleRequest.setRoleDefinitionId("9b895d92-2cd3-44c7-9d02-a6ac2d5ea5c3");
unifiedRoleAssignmentScheduleRequest.setDirectoryScopeId("/");
unifiedRoleAssignmentScheduleRequest.setJustification("Need to update app roles for selected apps.");
RequestSchedule scheduleInfo = new RequestSchedule();
OffsetDateTime startDateTime = OffsetDateTime.parse("2021-08-17T17:40:00.000Z");
scheduleInfo.setStartDateTime(startDateTime);
ExpirationPattern expiration = new ExpirationPattern();
expiration.setType(ExpirationPatternType.AfterDuration);
PeriodAndDuration duration = PeriodAndDuration.ofDuration(Duration.parse("PT5H"));
expiration.setDuration(duration);
scheduleInfo.setExpiration(expiration);
unifiedRoleAssignmentScheduleRequest.setScheduleInfo(scheduleInfo);
TicketInfo ticketInfo = new TicketInfo();
ticketInfo.setTicketNumber("CONTOSO:Normal-67890");
ticketInfo.setTicketSystem("MS Project");
unifiedRoleAssignmentScheduleRequest.setTicketInfo(ticketInfo);
UnifiedRoleAssignmentScheduleRequest result = graphClient.roleManagement().directory().roleAssignmentScheduleRequests().post(unifiedRoleAssignmentScheduleRequest);
const options = {
authProvider,
};
const client = Client.init(options);
const unifiedRoleAssignmentScheduleRequest = {
action: 'SelfActivate',
principalId: 'c6ad1942-4afa-47f8-8d48-afb5d8d69d2f',
roleDefinitionId: '9b895d92-2cd3-44c7-9d02-a6ac2d5ea5c3',
directoryScopeId: '/',
justification: 'Need to update app roles for selected apps.',
scheduleInfo: {
startDateTime: '2021-08-17T17:40:00.000Z',
expiration: {
type: 'AfterDuration',
duration: 'PT5H'
}
},
ticketInfo: {
ticketNumber: 'CONTOSO:Normal-67890',
ticketSystem: 'MS Project'
}
};
await client.api('/roleManagement/directory/roleAssignmentScheduleRequests/')
.version('beta')
.post(unifiedRoleAssignmentScheduleRequest);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\UnifiedRoleAssignmentScheduleRequest;
use Microsoft\Graph\Beta\Generated\Models\RequestSchedule;
use Microsoft\Graph\Beta\Generated\Models\ExpirationPattern;
use Microsoft\Graph\Beta\Generated\Models\ExpirationPatternType;
use Microsoft\Graph\Beta\Generated\Models\TicketInfo;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new UnifiedRoleAssignmentScheduleRequest();
$requestBody->setAction('SelfActivate');
$requestBody->setPrincipalId('c6ad1942-4afa-47f8-8d48-afb5d8d69d2f');
$requestBody->setRoleDefinitionId('9b895d92-2cd3-44c7-9d02-a6ac2d5ea5c3');
$requestBody->setDirectoryScopeId('/');
$requestBody->setJustification('Need to update app roles for selected apps.');
$scheduleInfo = new RequestSchedule();
$scheduleInfo->setStartDateTime(new \DateTime('2021-08-17T17:40:00.000Z'));
$scheduleInfoExpiration = new ExpirationPattern();
$scheduleInfoExpiration->setType(new ExpirationPatternType('afterDuration'));
$scheduleInfoExpiration->setDuration(new \DateInterval('PT5H'));
$scheduleInfo->setExpiration($scheduleInfoExpiration);
$requestBody->setScheduleInfo($scheduleInfo);
$ticketInfo = new TicketInfo();
$ticketInfo->setTicketNumber('CONTOSO:Normal-67890');
$ticketInfo->setTicketSystem('MS Project');
$requestBody->setTicketInfo($ticketInfo);
$result = $graphServiceClient->roleManagement()->directory()->roleAssignmentScheduleRequests()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Identity.Governance
$params = @{
action = "SelfActivate"
principalId = "c6ad1942-4afa-47f8-8d48-afb5d8d69d2f"
roleDefinitionId = "9b895d92-2cd3-44c7-9d02-a6ac2d5ea5c3"
directoryScopeId = "/"
justification = "Need to update app roles for selected apps."
scheduleInfo = @{
startDateTime = [System.DateTime]::Parse("2021-08-17T17:40:00.000Z")
expiration = @{
type = "AfterDuration"
duration = "PT5H"
}
}
ticketInfo = @{
ticketNumber = "CONTOSO:Normal-67890"
ticketSystem = "MS Project"
}
}
New-MgBetaRoleManagementDirectoryRoleAssignmentScheduleRequest -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.unified_role_assignment_schedule_request import UnifiedRoleAssignmentScheduleRequest
from msgraph_beta.generated.models.request_schedule import RequestSchedule
from msgraph_beta.generated.models.expiration_pattern import ExpirationPattern
from msgraph_beta.generated.models.expiration_pattern_type import ExpirationPatternType
from msgraph_beta.generated.models.ticket_info import TicketInfo
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = UnifiedRoleAssignmentScheduleRequest(
action = "SelfActivate",
principal_id = "c6ad1942-4afa-47f8-8d48-afb5d8d69d2f",
role_definition_id = "9b895d92-2cd3-44c7-9d02-a6ac2d5ea5c3",
directory_scope_id = "/",
justification = "Need to update app roles for selected apps.",
schedule_info = RequestSchedule(
start_date_time = "2021-08-17T17:40:00.000Z",
expiration = ExpirationPattern(
type = ExpirationPatternType.AfterDuration,
duration = "PT5H",
),
),
ticket_info = TicketInfo(
ticket_number = "CONTOSO:Normal-67890",
ticket_system = "MS Project",
),
)
result = await graph_client.role_management.directory.role_assignment_schedule_requests.post(request_body)
応答
次の例は応答を示しています。
注: ここに示す応答オブジェクトは、読みやすさのために短縮されている場合があります。
HTTP/1.1 201 Created
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#roleManagement/directory/roleAssignmentScheduleRequests/$entity",
"id": "163daf73-8746-4996-87de-ab71dc624bf9",
"status": "Granted",
"createdDateTime": "2021-08-17T17:39:36.7040696Z",
"completedDateTime": "2021-08-17T17:40:00Z",
"approvalId": null,
"customData": null,
"action": "SelfActivate",
"principalId": "c6ad1942-4afa-47f8-8d48-afb5d8d69d2f",
"roleDefinitionId": "9b895d92-2cd3-44c7-9d02-a6ac2d5ea5c3",
"directoryScopeId": "/",
"appScopeId": null,
"isValidationOnly": false,
"targetScheduleId": "163daf73-8746-4996-87de-ab71dc624bf9",
"justification": "Need to update app roles for selected apps.",
"createdBy": {
"application": null,
"device": null,
"user": {
"displayName": null,
"id": "c6ad1942-4afa-47f8-8d48-afb5d8d69d2f"
}
},
"scheduleInfo": {
"startDateTime": "2021-08-17T17:40:00Z",
"recurrence": null,
"expiration": {
"type": "afterDuration",
"endDateTime": null,
"duration": "PT5H"
}
},
"ticketInfo": {
"ticketNumber": "CONTOSO:Normal-67890",
"ticketSystem": "MS Project"
}
}