Remove group member

Removes a member from the specified group.

DELETE ~/api/directoryObjects/groupMembers?<parameters>

Query parameters

  • Name

  • Required

  • Type

  • Description

  • group

  • True

  • string

  • The identifier of the group to remove a member from. You can use:

     Distinguished name (DN)
    # Example
    CN=My Group,CN=Groups,DC=example,DC=com
    
     Globally unique identifier (GUID)
    # Example
    a7b63270-b8a4-4c34-b830-7e0d09f2e021
    
     Security identifier (SID)
    # Example
    S-1-5-21-3625849556-2655411187-3268999566-9847
    
  • member

  • True

  • string

  • The identifier of the member which should be removed. You can use:

     Distinguished name (DN)
    # Example
    CN=John Smith,CN=Users,DC=example,DC=com
    
     Globally unique identifier (GUID)
    # Example
    7a4267ce-d354-44e7-8bd6-c681f1284a41
    
     Security identifier (SID)
    # Example
    S-1-5-21-3635565734-1729062999-1822655016-1627
    

Request headers

  • Name

  • Required

  • Description

  • Adm-Authorization

  • True

  • Specify an access token.

Request body

Do not send a body with this request.

Responses

If successful, returns 200 OK status code and an operation result in the response body. Otherwise, returns one of the common HTTP error codes and an error description in the response body.

Examples

 Remove a group member

The following code sample removes a user from the specified group.

Request

PowerShell
Add-Type -AssemblyName System.Web
$baseUrl = "https://host.example.com/restApi"
$endpoint = "/api/directoryObjects/groupMembers"

# Request parameters
$memberIdentifier = [System.Web.HttpUtility]::UrlEncode("CN=John Smith,CN=Users,DC=example,DC=com")
$groupIdentifier = [System.Web.HttpUtility]::UrlEncode("CN=My Group,OU=Groups,DC=example,DC=com")
$queryParams = "?group=$groupIdentifier&member=$memberIdentifier"
$requestUrl = $baseUrl + $endpoint + $queryParams
$requestHeaders = @{"Adm-Authorization" = YOUR-ACCESS-TOKEN}

# Make request
Invoke-RestMethod -Method DELETE -Headers $requestHeaders -Uri $requestUrl
C#
using System;
using System.Net.Http;
using System.Threading.Tasks;

class Program
{
    static async Task Main()
    {
        const string baseUrl = "https://host.example.com";
        const string endpoint = "/restApi/api/directoryObjects/groupMembers";

        // Request parameters
        const string groupIdentifier = "CN=My Group,OU=Groups,DC=example,DC=com";
        const string memberIdentifier = "CN=John Smith,CN=Users,DC=example,DC=com";
        UriBuilder requestUrl = new()
        {
            Host = baseUrl + endpoint,
            Query = $"?group={groupIdentifier}" + $"&member={memberIdentifier}"
        };

        // Initialize HTTP client
        using HttpClient client = new();
        client.DefaultRequestHeaders.Add("Adm-Authorization", YOUR-ACCESS-TOKEN);

        // Make request
        HttpResponseMessage response = await client.DeleteAsync(requestUrl.ToString());
        string responseBody = response.Content.ReadAsStringAsync().Result;
        Console.WriteLine(responseBody);
    }
}
cURL
curl --header 'Adm-Authorization: YOUR-ACCESS-TOKEN' \
--get -X DELETE 'https://host.example.com/restApi/api/directoryObjects/groupMembers' \
--data-urlencode 'group=CN=My Group,OU=Groups,DC=example,DC=com' \
--data-urlencode 'member=CN=John Smith,CN=Users,DC=example,DC=com'
node.js
async function removeGroupMember() {
    // Request parameters
    const groupIdentifier = encodeURIComponent("CN=My Group,OU=Groups,DC=example,DC=com");
    const memberIdentifier = encodeURIComponent("CN=John Smith,CN=Users,DC=example,DC=com");

    const baseUrl = "https://host.example.com/restapi";
    const endpoint = "/api/directoryObjects/groupMembers";
    const queryParams = `?group=${groupIdentifier}&member=${memberIdentifier}`;
    const requestPath = `${baseUrl}${endpoint}${queryParams}`;

    // Make request
    const response = await fetch(requestPath, {
        method: "DELETE",
        headers: { "Adm-Authorization": "YOUR-ACCESS-TOKEN" }
    });

    if (!response.ok) {
        throw new Error(`Request failed with status ${response.status}`);
    }

    const result = await response.json();
    console.log(result);
}

removeGroupMember();
Python
import requests
import json

baseUrl = "https://host.example.com/restApi"
endpoint = "/api/directoryObjects/groupMembers"

# Request parameters
requestUrl = baseUrl + endpoint
requestHeaders = {"Adm-Authorization": YOUR-ACCESS-TOKEN}
queryParams = {
    "group": "CN=My Group,OU=Groups,DC=example,DC=com",
    "member": "CN=John Smith,CN=Users,DC=example,DC=com"
}   

# Make request
request = requests.delete(requestUrl, headers=requestHeaders, params=queryParams)
response = json.loads(request.content)
print(response)

Response

HTTP Status code: 200 OK
Response body:

{
    "resultType": 0,
    "innerMessages": [],
    "exception": null,
    "actualObjectDN": "CN=My Group,OU=Groups,DC=example,DC=com",
    "noChanges": false,
    "extraInfo": {}
}

See also