Search directory

Retrieves directory objects that fit the specified search criteria. This request can be used to retrieve business units.

POST ~/api/directoryObjects/search

In Adaxes 2021.1, use this request instead.

Request parameters

This request has no parameters.

Request headers

  • Name

  • Required

  • Description

  • Adm-Authorization

  • True

  • Specify the security token obtained during authentication.

Request body

The request body is a JSON object with the following data structure:

{
    "baseObject": "<objectId>",
    "oneLevel": <true|false>,
    "criteria": "<criteria>",
    "select": {
        "properties": "<propertyList>",
        "thumbnailPhoto": <"None"|"Normal"|"HighQuality">
    },
    "scope": <"All"|"TotpEnrolledAccounts">,
    "sizeLimit": <sizeLimit>
}

baseObject string, optional

The identifier of the container, organizational unit, or domain to search in. A base object can be identified by:

 Distinguished name (DN)
# Example
CN=My OU,DC=example,DC=com
 Globally unique identifier (GUID)
# Example
a7b63270-b8a4-4c34-b830-7e0d09f2e021

To search everywhere i.e. in all managed domains, don't specify this attribute in the request. To search for business units, specify wkobj:BusinessUnitsContainer, the well-known business unit container, as the attribute value.


oneLevel bool, optional

Set to true to only search across immediate children of the base object. If not specified or set to false, Adaxes will seacrh across the entire subtree of the base object. This attribute has no effect if the base object is not specified.


criteria Criteria, optional

The criteria for searching objects. For details on building criteria using PowerShell, see How to build criteria. You can also copy criteria from the criteria editor in Adaxes user interface – it will be copied into the clipboard as JSON.


select optional

The parameters for including object properties and photos in search results.

 Show attributes

select.properties string, optional

A comma-separated list of property names without whitespaces e.g. manager,department. Each object in search results will contain the values of specified properties. If not specified, objects will be retrieved with the default property set.

 Default property set
  • guid
  • dn
  • displayName
  • objectType
  • objectTypeCode
  • domainName
  • directoryType

select.thumbnailPhoto string, optional

Specify this attribute to include object photos in search results. Photos will be represented as a Base64-encoded string. Can be one of the following values:

  • Normal – included photos will be of normal quality.
  • HighQuality – included photos will be of high quality.
  • None – photos will not be included.

scope string, optional

Set to TotpEnrolledAccounts to search only across users who activated a mobile authenticator app in Adaxes. Set to All or omit this attribute to search across all objects.


sizeLimit int, optional

The maximum number of objects to retrieve. If not specified, every object that matches the search criteria will be retrieved.


Responses

  • If successful, returns 200 OK status code and an array of directory objects in the response body.
  • If successful, and there are no objects to retrieve, returns 200 OK status code and an empty array in the response body.
  • If unsuccessful, returns one of the common HTTP error codes and an error description in the response body.

The response will include only the objects that the authenticated user has the permissions to view. All permissions in Adaxes are granted by security roles.

Examples

 Example 1 – Find a user with a specific employee ID

The following code sample searches for a user with a specific employee ID in all managed domains.

Request

PowerShell
$baseUrl = "https://host.example.com/restApi"
$endpoint = "/api/directoryObjects/search"

# Request parameters
$requestUrl = $baseUrl + $endpoint 
$requestHeaders = @{"Adm-Authorization" = YOUR-SECURITY-TOKEN}

$criteria = New-AdmCriteria "User" {employeeID -eq "MyId12345"}
$requestBody = ConvertTo-Json -Depth 10 @{
    "criteria" = $criteria.ToDto();
    "select" = @{
        "properties" = "employeeId"
    }
}   

# Make request
Invoke-RestMethod -Method POST -Headers $requestHeaders -Uri $requestUrl `
    -Body $requestBody -ContentType "application/json"
C#
using System;
using System.Text;
using System.Net.Http;
using System.Threading.Tasks;
using Softerra.Adaxes.Directory.Criteria;

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

        // Create criteria.
        SimpleCriteriaItem item = new()
        {
            Property = "employeeID",
            Operator = "eq",
            Values = { "MyId12345" }
        };
        Criteria criteria = new();
        criteria.AddType("user", item);

        // Create JSON request body
        string jsonRequest = $@"
            {{
                'criteria': {criteria.ToJson(null)},
                'select': {{
                    'properties': 'employeeID'
                }}
            }}";
        StringContent requestBody = new(jsonRequest, Encoding.UTF8, "application/json");

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

        // Make request
        HttpResponseMessage response = await client.PostAsync(
            baseUrl + endpoint, requestBody);
        string responseBody = response.Content.ReadAsStringAsync().Result;
        Console.WriteLine(responseBody);
    }
}
cURL
curl  --header 'Adm-Authorization: YOUR-SECURITY-TOKEN' \
--header 'Content-Type: application/json' \
--request POST 'https://host.example.com/restApi/api/directoryObjects/search' \
--data-raw '{
    "criteria": {
        "objectTypes": [
            {
                "type": "User",
                "items": {
                    "type": 1,
                    "items": [
                        {
                            "type": 0,
                            "property": "employeeID",
                            "operator": "eq",
                            "values": [
                                {
                                    "type": 2,
                                    "value": "MyId12345"
                                }
                            ],
                            "valueLogicalOperator": 0
                        }
                    ],
                    "logicalOperator": 1
                }
            }
        ]
    },
    "select": {
        'properties': 'employeeID'
    }
}'
node.js
var https = require('https');

var options = {
    'method': 'POST',
    'hostname': 'host.example.com',
    'path': '/restapi/api/directoryObjects/search'
    'headers': {
        'Adm-Authorization': 'YOUR-SECURITY-TOKEN',
        'Content-Type': 'application/json'
    }
};

// Create JSON request body
var postData = `
{
    "criteria": {
        "objectTypes": [
            {
                "type": "User",
                "items": {
                    "type": 1,
                    "items": [
                        {
                            "type": 0,
                            "property": "employeeID",
                            "operator": "eq",
                            "values": [
                                {
                                    "type": 2,
                                    "value": "MyId12345"
                                }
                            ],
                            "valueLogicalOperator": 0
                        }
                    ],
                    "logicalOperator": 1
                }
            }
        ]
    },
    "select": {
        'properties': 'employeeID'
    }
}`;

// Make request
var req = https.request(options, res => {
    var data = [];

    res.on("data", chunk => {
        data.push(chunk);
    });

    res.on("end", () => {
        var body = Buffer.concat(data);
        console.log(body.toString());
    });

    res.on("error", error => {
        console.error(error);
    });
});
req.write(postData);

req.end();
Python
import requests
import json

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

# Request parameters
requestUrl = baseUrl + endpoint
requestHeaders = {"Adm-Authorization": YOUR-SECURITY-TOKEN}
requestBody = {
    "criteria": {
        "objectTypes": [
            {
                "type": "User",
                "items": {
                    "type": 1,
                    "items": [
                        {
                            "type": 0,
                            "property": "employeeID",
                            "operator": "eq",
                            "values": [
                                {
                                    "type": 2,
                                    "value": "MyId12345"
                                }
                            ],
                            "valueLogicalOperator": 0
                        }
                    ],
                    "logicalOperator": 1
                }
            }
        ]
    },
    "select": {
        "properties": "employeeID"
    }
}  

# Make request
request = requests.post(requestUrl, headers=requestHeaders, json=requestBody)
response = json.loads(request.content)
print(response)

Response

HTTP Status code: 200 OK
Response body:

[
    {
        "accountStatus": {
            "isDisabled": false,
            "isLocked": false,
            "expirationDate": null
        },
        "passwordStatus": {
            "whenChanged": "2020-09-03T14:18:48.974886Z",
            "expirationStatus": 0,
            "expirationDate": "2023-05-30T14:18:48.974886Z"
        },
        "guid": "13ce39d7-183d-41d7-9a6e-ad1ba85b4be3",
        "dn": "CN=Nick Johnston,OU=Sales,DC=example,DC=com",
        "displayName": "Nick Johnston",
        "objectType": "user",
        "objectTypeCode": 2,
        "domainName": "example.com",
        "directoryType": 1,
        "properties": {
            "employeeId": [
                "MyId12345"
            ]
        }
    }
]
 Example 2 – Retrieves all objects located directly under a specific OU

The following code sample retrieves all objects located directly under a specific organizational unit.

Request

PowerShell
$baseUrl = "https://host.example.com/restApi"
$endpoint = "/api/directoryObjects/search"

# Request parameters
$requestUrl = $baseUrl + $endpoint 
$requestHeaders = @{"Adm-Authorization" = YOUR-SECURITY-TOKEN}

$requestBody = ConvertTo-Json @{
    "baseObject" = "CN=My OU,DC=example,DC=com";
    "oneLevel" = $true
}   

# Make request
Invoke-RestMethod -Method POST -Headers $requestHeaders -Uri $requestUrl `
    -Body $requestBody -ContentType "application/json"
C#
using System;
using System.Text;
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/search";

        // Create JSON request body
        string jsonRequest = @"
            {
                'baseObject': 'CN=My OU,DC=example,DC=com',
                'oneLevel': true
            }";
        StringContent requestBody = new(jsonRequest, Encoding.UTF8, "application/json");

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

        // Make request
        HttpResponseMessage response = await client.PostAsync(
            baseUrl + endpoint, requestBody);
        string responseBody = response.Content.ReadAsStringAsync().Result;
        Console.WriteLine(responseBody);
    }
}
cURL
curl  --header 'Adm-Authorization: YOUR-SECURITY-TOKEN' \
--header 'Content-Type: application/json' \
--request POST 'https://host.example.com/restApi/api/directoryObjects/search' \
--data-raw '{
    "baseObject": "CN=My OU,DC=example,DC=com",
    "oneLevel": true
}'
node.js
var https = require('https');

var options = {
    'method': 'POST',
    'hostname': 'host.example.com',
    'path': '/restapi/api/directoryObjects/search'
    'headers': {
        'Adm-Authorization': 'YOUR-SECURITY-TOKEN',
        'Content-Type': 'application/json'
    }
};

// Create JSON request body
var postData = `
{
    "baseObject": "CN=My OU,DC=example,DC=com",
    "oneLevel": true
}`;

// Make request
var req = https.request(options, res => {
    var data = [];

    res.on("data", chunk => {
        data.push(chunk);
    });

    res.on("end", () => {
        var body = Buffer.concat(data);
        console.log(body.toString());
    });

    res.on("error", error => {
        console.error(error);
    });
});
req.write(postData);

req.end();
Python
import requests
import json

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

# Request parameters
requestUrl = baseUrl + endpoint
requestHeaders = {"Adm-Authorization": YOUR-SECURITY-TOKEN}
requestBody = {
    "baseObject": "CN=My OU,DC=example,DC=com",
    "oneLevel": true
}  

# Make request
request = requests.post(requestUrl, headers=requestHeaders, json=requestBody)
response = json.loads(request.content)
print(response)

Response

HTTP Status code: 200 OK
Response body:

[
    {
        "accountStatus": {
            "isDisabled": true,
            "isLocked": false,
            "expirationDate": null
        },
        "passwordStatus": {
            "whenChanged": "2020-10-01T12:26:50.4085035Z",
            "expirationStatus": 1,
            "expirationDate": null
        },
        "guid": "2288a376-ef17-4319-8dea-edc291cf892a",
        "dn": "CN=John Sally,OU=My OU,DC=example,DC=com",
        "displayName": "John Sally",
        "objectType": "user",
        "objectTypeCode": 2,
        "domainName": "example.com",
        "directoryType": 1,
        "properties": {}
    },
    {
        "accountStatus": {
            "isDisabled": false,
            "isLocked": true,
            "expirationDate": null
        },
        "passwordStatus": {
            "whenChanged": "2020-10-01T12:26:50.1585044Z",
            "expirationStatus": 1,
            "expirationDate": null
        },
        "guid": "4bd4e1ed-be88-457c-ae6e-6aece10fc621",
        "dn": "CN=Anna Park,OU=My OU,DC=example,DC=com",
        "displayName": "Anna Park",
        "objectType": "user",
        "objectTypeCode": 2,
        "domainName": "example.com",
        "directoryType": 1,
        "properties": {}
    }
 Example 3 – Retrieve all users from a specific domain, who are enrolled for MFA in Adaxes

The following code sample retrieves all users from a specific domain who activated a mobile authenticator app in Adaxes.

Request

PowerShell
$baseUrl = "https://host.example.com/restApi"
$endpoint = "/api/directoryObjects/search"

# Request parameters
$requestUrl = $baseUrl + $endpoint 
$requestHeaders = @{"Adm-Authorization" = YOUR-SECURITY-TOKEN}

$requestBody = ConvertTo-Json @{
    "baseObject" = "DC=example,DC=com";
    "scope" = "TotpEnrolledAccounts"
}   

# Make request
Invoke-RestMethod -Method POST -Headers $requestHeaders -Uri $requestUrl `
    -Body $requestBody -ContentType "application/json"
C#
using System;
using System.Text;
using System.Net.Http;
using System.Threading.Tasks;
using Softerra.Adaxes.Directory.Criteria;

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

        // Create JSON request body
        string jsonRequest = @"
            {
                'baseObject': 'DC=example,DC=com',
                'scope': 'TotpEnrolledAccounts'
            }";
        StringContent requestBody = new(jsonRequest, Encoding.UTF8, "application/json");

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

        // Make request
        HttpResponseMessage response = await client.PostAsync(
            baseUrl + endpoint, requestBody);
        string responseBody = response.Content.ReadAsStringAsync().Result;
        Console.WriteLine(responseBody);
    }
}
cURL
curl  --header 'Adm-Authorization: YOUR-SECURITY-TOKEN' \
--header 'Content-Type: application/json' \
--request POST 'https://host.example.com/restApi/api/directoryObjects/search' \
--data-raw '{
    "baseObject": "DC=example,DC=com"
    "scope": "TotpEnrolledAccounts"
}'
node.js
var https = require('https');

var options = {
    'method': 'POST',
    'hostname': 'host.example.com',
    'path': '/restapi/api/directoryObjects/search'
    'headers': {
        'Adm-Authorization': 'YOUR-SECURITY-TOKEN',
        'Content-Type': 'application/json'
    }
};

// Create JSON request body
var postData = `
{
    "baseObject": "DC=example,DC=com",
    "scope": "TotpEnrolledAccounts"
}`;

// Make request
var req = https.request(options, res => {
    var data = [];

    res.on("data", chunk => {
        data.push(chunk);
    });

    res.on("end", () => {
        var body = Buffer.concat(data);
        console.log(body.toString());
    });

    res.on("error", error => {
        console.error(error);
    });
});
req.write(postData);

req.end();
Python
import requests
import json

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

# Request parameters
requestUrl = baseUrl + endpoint
requestHeaders = {"Adm-Authorization": YOUR-SECURITY-TOKEN}
requestBody = {
    "baseObject": "DC=example,DC=com",
    "scope": "TotpEnrolledAccounts"
}  

# Make request
request = requests.post(requestUrl, headers=requestHeaders, json=requestBody)
response = json.loads(request.content)
print(response)

Response

HTTP Status code: 200 OK
Response body:

[
    {
        "accountStatus": {
            "isDisabled": false,
            "isLocked": false,
            "expirationDate": null
        },
        "passwordStatus": {
            "whenChanged": "2020-10-01T12:26:50.1585044Z",
            "expirationStatus": 1,
            "expirationDate": null
        },
        "guid": "4bd4e1ed-be88-457c-ae6e-6aece10fc621",
        "dn": "CN=Anna Park,CN=Users,DC=example,DC=com",
        "displayName": "Anna Park",
        "objectType": "user",
        "objectTypeCode": 2,
        "domainName": "example.com",
        "directoryType": 1,
        "properties": {}
    },
    {
        "accountStatus": {
            "isDisabled": true,
            "isLocked": false,
            "expirationDate": null
        },
        "passwordStatus": {
            "whenChanged": null,
            "expirationStatus": 1,
            "expirationDate": null
        },
        "guid": "7a53db58-87cd-4502-a8b1-d68d5a30bf44",
        "dn": "CN=Alfred Junior,CN=Users,DC=example,DC=com",
        "displayName": "Alfred Junior",
        "objectType": "user",
        "objectTypeCode": 2,
        "domainName": "example.com",
        "directoryType": 1,
        "properties": {}
    }
]
 Example 4 – Retrieve the emails, mobile numbers, and photos of all users

The following code sample retrieves all users and their properties:

  • Email
  • Mobile Phone
  • Picture

Request

PowerShell
    $baseUrl = "https://host.example.com/restApi"
$endpoint = "/api/directoryObjects/search"

# Request parameters
$requestUrl = $baseUrl + $endpoint 
$requestHeaders = @{"Adm-Authorization" = YOUR-SECURITY-TOKEN}

$requestBody = ConvertTo-Json -Depth 3 @{
    "select" = @{
        "properties" = "mail,mobile";
        "thumbnailPhoto" = "Normal"
    }
}   

# Make request
Invoke-RestMethod -Method POST -Headers $requestHeaders -Uri $requestUrl `
    -Body $requestBody -ContentType "application/json"
C#
using System;
using System.Text;
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/search";

        // Create JSON request body
        string jsonRequest = @"
            {
                'select': {
                    'properties': 'mail,mobile',
                    'thumbnailPhoto': 'Normal'
                }
            }";
        StringContent requestBody = new(jsonRequest, Encoding.UTF8, "application/json");

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

        // Make request
        HttpResponseMessage response = await client.PostAsync(
            baseUrl + endpoint, requestBody);
        string responseBody = response.Content.ReadAsStringAsync().Result;
        Console.WriteLine(responseBody);
    }
}
cURL
curl  --header 'Adm-Authorization: YOUR-SECURITY-TOKEN' \
--header 'Content-Type: application/json' \
--request POST 'https://host.example.com/restApi/api/directoryObjects/search' \
--data-raw '{
    "select": {
        "properties": "mail,mobile",
        "thumbnailPhoto": "Normal"
    }
}'
node.js
var https = require('https');

var options = {
    'method': 'POST',
    'hostname': 'host.example.com',
    'path': '/restapi/api/directoryObjects/search'
    'headers': {
        'Adm-Authorization': 'YOUR-SECURITY-TOKEN',
        'Content-Type': 'application/json'
    }
};

// Create JSON request body
var postData = `
{
    "select": {
        "properties": "mail,mobile",
        "thumbnailPhoto": "Normal"
    }
}`;

// Make request
var req = https.request(options, res => {
    var data = [];

    res.on("data", chunk => {
        data.push(chunk);
    });

    res.on("end", () => {
        var body = Buffer.concat(data);
        console.log(body.toString());
    });

    res.on("error", error => {
        console.error(error);
    });
});
req.write(postData);

req.end();
Python
import requests
import json

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

# Request parameters
requestUrl = baseUrl + endpoint
requestHeaders = {"Adm-Authorization": YOUR-SECURITY-TOKEN}
requestBody = {
    "select": {
        "properties": "mail,mobile",
        "thumbnailPhoto": "Normal"
    }
}  

# Make request
request = requests.post(requestUrl, headers=requestHeaders, json=requestBody)
response = json.loads(request.content)
print(response)

Response

HTTP Status code: 200 OK
Response body:

[
    {
        "accountStatus": {
            "isDisabled": false,
            "isLocked": false,
            "expirationDate": null
        },
        "passwordStatus": {
            "whenChanged": "2020-10-01T12:26:50.1585044Z",
            "expirationStatus": 1,
            "expirationDate": null
        },
        "guid": "4bd4e1ed-be88-457c-ae6e-6aece10fc621",
        "dn": "CN=Anna Park,CN=Users,DC=example,DC=com",
        "displayName": "Anna Park",
        "objectType": "user",
        "objectTypeCode": 2,
        "domainName": "example.com",
        "directoryType": 1,
        "properties": {
            "mail": [ "anna.park@example.com" ],
            "mobile": [ "908-432-9108" ]
        },
        "thumbnailPhoto": "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAAR
        nQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAzkSURBVFhHPZZ3eFVltsZPejvJyTk5yennpBcIk
        YQiRCCkkkpCElIJKSRgQighdJCEKpAIxNloMFKkI3gBAQvIDIqgKCpYgg9jRWccS3S8oN1njvP764dvfPHeva3
        v7LWu971fmtvzYlVURUbmhKV2Tk2ZU5uLKwJFppKXDJ2KG05FuUolS90prrq3QUeysVqQbl2LZxypeXqZcViKV
        nR2yJ9NNGVgepxzblK7sak1QHu8cpywqNSvzcryVbU3+SmeJVtlaa1a2to5WtjZFKkd6ZiutmV7KshIv5WRv/+
        YmRBlhcf/HE98Dn/2kJp3cksbLIxObGSSwoSaEqNZRl001sbwhlfZU322Z7s"
    },
    {
        "accountStatus": {
            "isDisabled": true,
            "isLocked": false,
            "expirationDate": null
        },
        "passwordStatus": {
            "whenChanged": null,
            "expirationStatus": 1,
            "expirationDate": null
        },
        "guid": "7a53db58-87cd-4502-a8b1-d68d5a30bf44",
        "dn": "CN=Alfred Junior,CN=Users,DC=example,DC=com",
        "displayName": "Alfred Junior",
        "objectType": "user",
        "objectTypeCode": 2,
        "domainName": "example.com",
        "directoryType": 1,
        "properties": {
            "mail": [ "alfred.junior@example.com" ],
            "mobile": [ "405-657-0062" ]
        },
        "thumbnailPhoto": "nY2enKq24ObL1aoJdApdVl6ZqYHsbHBjx2tgdL1AsmeEEBBqp/Ma3loli/71spVzfJnqbTY
        +SUBfPL+W9w6f5g7z+zktYEubjy+hT+fO8LH5wXQ2T5+ffMwN5+UZjXVnaUzndRO8mLmZ6UjdZkHx7s8GfpovgDIDV
        TqMwKZV6Qla7z0AMl8cYnoIdubixfZmRoqcnw4fFOvbRmX0omeTCv1M5Xf36XG8cU3tzfLSB6eXt3Fx+fHOAvLx4UB
        o7x/dUBjq5ysrjQjfnTjZTc70XZGA+Kkj2oGu/+9oczOz8QGbl+NE504dGYaciI42v797ig0tHOb+1nfef3spXV4/y
        99uX+On2Of77"
    }
]
 Example 5 – Retrieve all business units

The following code sample retrieves all business units.

Request

PowerShell
$baseUrl = "https://host.example.com/restApi"
$endpoint = "/api/directoryObjects/search"

# Request parameters
$requestUrl = $baseUrl + $endpoint 
$requestHeaders = @{"Adm-Authorization" = YOUR-SECURITY-TOKEN}

$requestBody = ConvertTo-Json @{
    "baseObject" = "wkobj:BusinessUnitsContainer"
}   

# Make request
Invoke-RestMethod -Method POST -Headers $requestHeaders -Uri $requestUrl `
    -Body $requestBody -ContentType "application/json"
C#
using System;
using System.Text;
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/search";

        // Create JSON request body
        string jsonRequest = @"
            {
                'baseObject': 'wkobj:BusinessUnitsContainer'
            }";
        StringContent requestBody = new(jsonRequest, Encoding.UTF8, "application/json");

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

        // Make request
        HttpResponseMessage response = await client.PostAsync(
            baseUrl + endpoint, requestBody);
        string responseBody = response.Content.ReadAsStringAsync().Result;
        Console.WriteLine(responseBody);
    }
}
cURL
curl  --header 'Adm-Authorization: YOUR-SECURITY-TOKEN' \
--header 'Content-Type: application/json' \
--request POST 'https://host.example.com/restApi/api/directoryObjects/search' \
--data-raw '{
    "baseObject": "wkobj:BusinessUnitsContainer"
}'
node.js
var https = require('https');

var options = {
    'method': 'POST',
    'hostname': 'host.example.com',
    'path': '/restapi/api/directoryObjects/search'
    'headers': {
        'Adm-Authorization': 'YOUR-SECURITY-TOKEN',
        'Content-Type': 'application/json'
    }
};

// Create JSON request body
var postData = `
{
    "baseObject": "wkobj:BusinessUnitsContainer"
}`;

// Make request
var req = https.request(options, res => {
    var data = [];

    res.on("data", chunk => {
        data.push(chunk);
    });

    res.on("end", () => {
        var body = Buffer.concat(data);
        console.log(body.toString());
    });

    res.on("error", error => {
        console.error(error);
    });
});
req.write(postData);

req.end();
Python
import requests
import json

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

# Request parameters
requestUrl = baseUrl + endpoint
requestHeaders = {"Adm-Authorization": YOUR-SECURITY-TOKEN}
requestBody = {
    "baseObject": "wkobj:BusinessUnitsContainer"
}  

# Make request
request = requests.post(requestUrl, headers=requestHeaders, json=requestBody)
response = json.loads(request.content)
print(response)

Response

HTTP Status code: 200 OK
Response body:

[
    {
        "rootContainerDN": "CN=Business Units,CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes",
        "guid": "742a1aab-99ee-48c7-8a3a-97d8d26988e0",
        "dn": "CN=My Unit,CN=Business Units,CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes",
        "displayName": "My Unit",
        "objectType": "adm-BusinessUnit",
        "objectTypeCode": 100,
        "domainName": "",
        "properties": {}
    },
    {
        "rootContainerDN": "CN=Business Units,CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes",
        "guid": "4239a090-2915-4b05-b808-b5610595fa8b",
        "dn": "CN=Deprovisioned Users,CN=Business Units,CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes",
        "displayName": "Deprovisioned Users",
        "objectType": "adm-BusinessUnit",
        "objectTypeCode": 100,
        "domainName": "",
        "properties": {}
    }
]

See also