You can specify the following properties when creating an unifiedRoleAssignmentScheduleRequest.
Property
Type
Description
action
unifiedRoleScheduleRequestActions
Represents the type of the operation on the role assignment request. The possible values are: adminAssign, adminUpdate, adminRemove, selfActivate, selfDeactivate, adminExtend, adminRenew, selfExtend, selfRenew, unknownFutureValue.
adminAssign: For administrators to assign roles to users or groups.
adminRemove: For administrators to remove users or groups from roles.
adminUpdate: For administrators to change existing role assignments.
adminExtend: For administrators to extend expiring assignments.
adminRenew: For administrators to renew expired assignments.
selfActivate: For users to activate their assignments.
selfDeactivate: For users to deactivate their active assignments.
selfExtend: For users to request to extend their expiring assignments.
selfRenew: For users to request to renew their expired assignments.
customData
String
Free text field to define any custom data for the request. Optional.
principalId
String
Identifier of the principal that has been granted the assignment. Required.
Identifier of the directory object representing the scope of the assignment. The scope of an assignment determines the set of resources for which the principal has been granted access. Directory scopes are shared scopes stored in the directory that are understood by multiple applications. Use / for tenant-wide scope. Use appScopeId to limit the scope to an application only. Either directoryScopeId or appScopeId is required.
appScopeId
String
Identifier of the app-specific scope when the assignment is scoped to an app. The scope of an assignment determines the set of resources for which the principal has been granted access. App scopes are scopes that are defined and understood by this application only. Use / for tenant-wide app scopes. Use directoryScopeId to limit the scope to particular directory objects, for example, administrative units. Either directoryScopeId or appScopeId is required.
justification
String
A message provided by users and administrators when create they create the unifiedRoleAssignmentScheduleRequest object. Optional.
Example 1: Admin assigning a directory role to a principal
In the following request, the admin creates a request to assign a role identified by fdd7a751-b60b-444a-984c-02652fe8fa1c to a principal identified by ID 071cc716-8147-4397-a5ba-b2105951cc0b. The scope of their role is all directory objects in the tenant and the assignment is permanent.
POST https://graph.microsoft.com/v1.0/roleManagement/directory/roleAssignmentScheduleRequests
Content-Type: application/json
{
"action": "adminAssign",
"justification": "Assign Groups Admin to IT Helpdesk group",
"roleDefinitionId": "fdd7a751-b60b-444a-984c-02652fe8fa1c",
"directoryScopeId": "/",
"principalId": "071cc716-8147-4397-a5ba-b2105951cc0b",
"scheduleInfo": {
"startDateTime": "2022-04-10T00:00:00Z",
"expiration": {
"type": "NoExpiration"
}
}
}
// Code snippets are only available for the latest version. Current version is 5.x
var graphClient = new GraphServiceClient(requestAdapter);
var requestBody = new UnifiedRoleAssignmentScheduleRequest
{
Action = UnifiedRoleScheduleRequestActions.AdminAssign,
Justification = "Assign Groups Admin to IT Helpdesk group",
RoleDefinitionId = "fdd7a751-b60b-444a-984c-02652fe8fa1c",
DirectoryScopeId = "/",
PrincipalId = "071cc716-8147-4397-a5ba-b2105951cc0b",
ScheduleInfo = new RequestSchedule
{
StartDateTime = DateTimeOffset.Parse("2022-04-10T00:00:00Z"),
Expiration = new ExpirationPattern
{
Type = ExpirationPatternType.NoExpiration,
},
},
};
var result = await graphClient.RoleManagement.Directory.RoleAssignmentScheduleRequests.PostAsync(requestBody);
<?php
// THIS SNIPPET IS A PREVIEW VERSION OF THE SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new UnifiedRoleAssignmentScheduleRequest();
$requestBody->setAction(new UnifiedRoleScheduleRequestActions('adminAssign'));
$requestBody->setJustification('Assign Groups Admin to IT Helpdesk group');
$requestBody->setRoleDefinitionId('fdd7a751-b60b-444a-984c-02652fe8fa1c');
$requestBody->setDirectoryScopeId('/');
$requestBody->setPrincipalId('071cc716-8147-4397-a5ba-b2105951cc0b');
$scheduleInfo = new RequestSchedule();
$scheduleInfo->setStartDateTime(new \DateTime('2022-04-10T00:00:00Z'));
$scheduleInfoExpiration = new ExpirationPattern();
$scheduleInfoExpiration->setType(new ExpirationPatternType('noExpiration'));
$scheduleInfo->setExpiration($scheduleInfoExpiration);
$requestBody->setScheduleInfo($scheduleInfo);
$result = $graphServiceClient->roleManagement()->directory()->roleAssignmentScheduleRequests()->post($requestBody)->wait();
In the following request, a user identified by principalId071cc716-8147-4397-a5ba-b2105951cc0b activates their own eligible role to an Azure AD role identified by ID 8424c6f0-a189-499e-bbd0-26c1753c96d4. The scope of their role is all directory objects in the tenant and the assignment is for five hours. To run this request, the calling user must have multi-factor authentication (MFA) enforced, and running the query in a session in which they were challenged for MFA.
POST https://graph.microsoft.com/v1.0/roleManagement/directory/roleAssignmentScheduleRequests/
Content-Type: application/json
{
"action": "selfActivate",
"principalId": "071cc716-8147-4397-a5ba-b2105951cc0b",
"roleDefinitionId": "8424c6f0-a189-499e-bbd0-26c1753c96d4",
"directoryScopeId": "/",
"justification": "I need access to the Attribute Administrator role to manage attributes to be assigned to restricted AUs",
"scheduleInfo": {
"startDateTime": "2022-04-14T00:00: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
var graphClient = new GraphServiceClient(requestAdapter);
var requestBody = new UnifiedRoleAssignmentScheduleRequest
{
Action = UnifiedRoleScheduleRequestActions.SelfActivate,
PrincipalId = "071cc716-8147-4397-a5ba-b2105951cc0b",
RoleDefinitionId = "8424c6f0-a189-499e-bbd0-26c1753c96d4",
DirectoryScopeId = "/",
Justification = "I need access to the Attribute Administrator role to manage attributes to be assigned to restricted AUs",
ScheduleInfo = new RequestSchedule
{
StartDateTime = DateTimeOffset.Parse("2022-04-14T00:00:00.000Z"),
Expiration = new ExpirationPattern
{
Type = ExpirationPatternType.AfterDuration,
Duration = TimeSpan.Parse("PT5H"),
},
},
TicketInfo = new TicketInfo
{
TicketNumber = "CONTOSO:Normal-67890",
TicketSystem = "MS Project",
},
};
var result = await graphClient.RoleManagement.Directory.RoleAssignmentScheduleRequests.PostAsync(requestBody);
// THE CLI IS IN PREVIEW. NON-PRODUCTION USE ONLY
mgc role-management directory role-assignment-schedule-requests create --body '{\
"action": "selfActivate",\
"principalId": "071cc716-8147-4397-a5ba-b2105951cc0b",\
"roleDefinitionId": "8424c6f0-a189-499e-bbd0-26c1753c96d4",\
"directoryScopeId": "/",\
"justification": "I need access to the Attribute Administrator role to manage attributes to be assigned to restricted AUs",\
"scheduleInfo": {\
"startDateTime": "2022-04-14T00:00:00.000Z",\
"expiration": {\
"type": "AfterDuration",\
"duration": "PT5H"\
}\
},\
"ticketInfo": {\
"ticketNumber": "CONTOSO:Normal-67890",\
"ticketSystem": "MS Project"\
}\
}\
'
<?php
// THIS SNIPPET IS A PREVIEW VERSION OF THE SDK. NON-PRODUCTION USE ONLY
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new UnifiedRoleAssignmentScheduleRequest();
$requestBody->setAction(new UnifiedRoleScheduleRequestActions('selfActivate'));
$requestBody->setPrincipalId('071cc716-8147-4397-a5ba-b2105951cc0b');
$requestBody->setRoleDefinitionId('8424c6f0-a189-499e-bbd0-26c1753c96d4');
$requestBody->setDirectoryScopeId('/');
$requestBody->setJustification('I need access to the Attribute Administrator role to manage attributes to be assigned to restricted AUs');
$scheduleInfo = new RequestSchedule();
$scheduleInfo->setStartDateTime(new \DateTime('2022-04-14T00:00: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();
# THE PYTHON SDK IS IN PREVIEW. FOR NON-PRODUCTION USE ONLY
graph_client = GraphServiceClient(request_adapter)
request_body = UnifiedRoleAssignmentScheduleRequest(
action = UnifiedRoleScheduleRequestActions.SelfActivate,
principal_id = "071cc716-8147-4397-a5ba-b2105951cc0b",
role_definition_id = "8424c6f0-a189-499e-bbd0-26c1753c96d4",
directory_scope_id = "/",
justification = "I need access to the Attribute Administrator role to manage attributes to be assigned to restricted AUs",
schedule_info = RequestSchedule(
start_date_time = "2022-04-14T00:00: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(body = request_body)