Remove directory role member

Namespace: microsoft.graph

Remove a member from a directoryRole.

You can use both the object ID and template ID of the directoryRole with this API. The template ID of a built-in role is immutable and can be seen in the role description on the Azure portal. For details, see Role template IDs.

Permissions

One of the following permissions is required to call this API. To learn more, including how to choose permissions, see Permissions.

Permission type Permissions (from least to most privileged)
Delegated (work or school account) RoleManagement.ReadWrite.Directory
Delegated (personal Microsoft account) Not supported.
Application RoleManagement.ReadWrite.Directory

HTTP request

You can address the directory role using either its id or roleTemplateId.

DELETE /directoryRoles/{role-id}/members/{id}/$ref
DELETE /directoryRoles(roleTemplateId='{roleTemplateId}')/members/{id}/$ref

Caution

If /$ref is not appended to the request and the calling app has permissions to manage the member object, the object will also be deleted from Azure Active Directory (Azure AD); otherwise, a 403 Forbidden error is returned. You can restore specific objects through the Restore deleted items API.

Request headers

Name Description
Authorization Bearer {token}. Required.

Request body

Do not supply a request body for this method.

Response

If successful, this method returns a 204 No Content response code. It does not return anything in the response body.

Examples

Example 1: Remove directory role member using role id

Request

In this example, replace f8e85ed8-f66f-4058-b170-3efae8b9c6e5 with the id value of the directory role and bb165b45-151c-4cf6-9911-cd7188912848 with the id value of the user or directory object that you wish to unassign from the directory role.

DELETE https://graph.microsoft.com/v1.0/directoryRoles/f8e85ed8-f66f-4058-b170-3efae8b9c6e5/members/bb165b45-151c-4cf6-9911-cd7188912848/$ref

Response

HTTP/1.1 204 No Content

Example 2: Remove directory role member using roleTemplateId

Request

The following is an example of the request. Replace 9f06204d-73c1-4d4c-880a-6edb90606fd8 with the value of your roleTemplateId and bb165b45-151c-4cf6-9911-cd7188912848 with the id value of your user of directory object.

DELETE https://graph.microsoft.com/v1.0/directoryRoles(roleTemplateId='9f06204d-73c1-4d4c-880a-6edb90606fd8')/members/bb165b45-151c-4cf6-9911-cd7188912848/$ref

Response

HTTP/1.1 204 No Content