Get business unit members

Retrieves all members of a business unit. To get the business unit itself, use the Get directory object or Search directory requests.

GET ~/api/directoryObjects/businessUnitMembers?<parameters>

Query parameters

  • Name

  • Required

  • Type

  • Description

  • businessUnit

  • True

  • string

  • The identifier of the business unit whose members to retrieve. You can use:

     Distinguished name (DN)
    # Example
    CN=My Unit,CN=Business Units,CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes
    

    For information on how to get the distinguished name of a business unit, see Get the DN of a directory object.

     Business unit identifier (adm-ObjectID)
    # Example
    a7b63270-b8a4-4c34-b830-7e0d09f2e021
    

    For information on how to get the identifier of a business unit, see Get Adaxes configuration object identifier.

  • properties

  • False

  • string

  • A comma-separated list of property names without whitespaces e.g. manager,department. Each retrieved object 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
  • sizeLimit

  • False

  • integer

  • The maximum number of objects to retrieve. If not specified, every member of the business unit will be retrieved.

Request headers

  • Name

  • Required

  • Description

  • Adm-Authorization

  • True

  • Specify the security token obtained during authentication.

Request body

Do not send a body with this request.

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.

Only objects that the authenticated user has the permissions to view will be included in the response. All permissions in Adaxes are granted by security roles.

Examples

 Example 1 – Retrieve business unit members

The following code sample retrieves all members of a specific business unit.

Request

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

# Request parameters
$requestUrl = $baseUrl + $endpoint
$requestHeaders = @{"Adm-Authorization" = YOUR-SECURITY-TOKEN}
$queryParams = @{"businessUnit" = 
    "CN=My Unit,CN=Business Units,CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes"}

# Make request
Invoke-RestMethod -Method GET -Headers $requestHeaders -Uri $requestUrl -Body $queryParams
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/businessUnitMembers";            
        
        // Request parameters
        const string unitIdentifier = 
            "CN=My Unit,CN=Business Units,CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes";
        UriBuilder requestUrl = new()
        {
            Host = baseUrl + endpoint,
            Query = $"?businessUnit={unitIdentifier}"
        };   

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

        // Make request
        string response = await client.GetStringAsync(requestUrl.ToString());
        Console.WriteLine(response);
    }
}
cURL
curl  --header 'Adm-Authorization: YOUR-SECURITY-TOKEN' \
--get -X GET 'https://host.example.com/restApi/api/directoryObjects/businessUnitMembers' \
--data-urlencode 'businessUnit=CN=My Unit,CN=Business Units,CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes'
node.js
var https = require('https');

// Request parameters
var unitIdentifier = "CN=My Unit,CN=Business Units,CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes";
var requestPath = "/restApi/api/directoryObjects/businessUnitMembers"
    + `?businessUnit=${unitIdentifier}`;
    
var options = {
    'method': 'GET',
    'hostname': 'host.example.com',
    'path': encodeURI(requestPath),
    'headers': {'Adm-Authorization': 'YOUR-SECURITY-TOKEN'}
};

// 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.end();
Python
import requests
import json

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

# Request parameters
requestUrl = baseUrl + endpoint
requestHeaders = {"Adm-Authorization": YOUR-SECURITY-TOKEN}
queryParams = {"businessUnit": "CN=My Unit,CN=Business Units,CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes"}

# Make request
request = requests.get(requestUrl, headers=requestHeaders, params=queryParams)
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": {}
    },
    {
        "accountStatus": {
            "isDisabled": false,
            "isLocked": false,
            "expirationDate": null
        },
        "passwordStatus": {
            "whenChanged": "2020-09-03T14:28:37.1314138Z",
            "expirationStatus": 0,
            "expirationDate": "2023-05-30T14:28:37.1314138Z"
        },
        "guid": "073ea181-87a7-46ea-8f4e-c0e3345c7bb8",
        "dn": "CN=Andy James,OU=Marketing,DC=example,DC=com",
        "displayName": "Andy James",
        "objectType": "user",
        "objectTypeCode": 2,
        "domainName": "example.com",
        "directoryType": 1,
        "properties": {}
    }
]
 Example 2 – Retrieve business unit members with their department and account expiration date

The following code sample retrieves all members of a specific business unit and their values of the following properties:

  • Department
  • Account expires

Request

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

# Request parameters
$requestUrl = $baseUrl + $endpoint
$requestHeaders = @{"Adm-Authorization" = YOUR-SECURITY-TOKEN}
$queryParams = @{
    "businessUnit" = "CN=My Unit,CN=Business Units,CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes";
    "properties" = "department,accountExpires"
}

# Make request
Invoke-RestMethod -Method GET -Headers $requestHeaders -Uri $requestUrl -Body $queryParams
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/businessUnitMembers";            
        
        // Request parameters
        const string unitIdentifier = "CN=My Unit,CN=Business Units,CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes";
        const string propertiesToGet = "department,accountExpires";
        UriBuilder requestUrl = new()
        {
            Host = baseUrl + endpoint,
            Query = $"?businessUnit={unitIdentifier}" + $"&properties={propertiesToGet}"
        };   

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

        // Make request
        string response = await client.GetStringAsync(requestUrl.ToString());
        Console.WriteLine(response);
    }
}
cURL
curl  --header 'Adm-Authorization: YOUR-SECURITY-TOKEN' \
--get -X GET 'https://host.example.com/restApi/api/directoryObjects/businessUnitMembers' \
--data-urlencode 'businessUnit=CN=My Unit,CN=Business Units,CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes' \
--data-urlencode 'properties=department,accountExpires'
node.js
var https = require('https');

// Request parameters
var unitIdentifier = encodeURIComponent("CN=My Unit,CN=Business Units,CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes");
var propertiesToGet = "department,accountExpires";
var requestPath = "/restApi/api/directoryObjects/businessUnitMembers"
    + `?businessUnit=${unitIdentifier}`
    + `&properties=${propertiesToGet}`;
    
var options = {
    'method': 'GET',
    'hostname': 'host.example.com',
    'path': requestPath,
    'headers': {'Adm-Authorization': 'YOUR-SECURITY-TOKEN'}
};

// 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.end();
Python
import requests
import json

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

# Request parameters
requestUrl = baseUrl + endpoint
requestHeaders = {"Adm-Authorization": YOUR-SECURITY-TOKEN}
queryParams = {
    "businessUnit": "CN=My Unit,CN=Business Units,CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes",
    "properties": "department,accountExpires"
}

# Make request
request = requests.get(requestUrl, headers=requestHeaders, params=queryParams)
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": {
            "department": [
                "Sales"
            ],
            "accountexpires": [
                "never"
            ]
        }
    },
    {
        "accountStatus": {
            "isDisabled": false,
            "isLocked": false,
            "expirationDate": null
        },
        "passwordStatus": {
            "whenChanged": "2020-09-03T14:28:37.1314138Z",
            "expirationStatus": 0,
            "expirationDate": "2023-05-30T14:28:37.1314138Z"
        },
        "guid": "073ea181-87a7-46ea-8f4e-c0e3345c7bb8",
        "dn": "CN=Andy James,OU=Marketing,DC=example,DC=com",
        "displayName": "Andy James",
        "objectType": "user",
        "objectTypeCode": 2,
        "domainName": "example.com",
        "directoryType": 1,
        "properties": {
            "department": [
                "Marketing"
            ],
            "accountexpires": [
                "2021-02-03T14:19:38.9936927Z"
            ]
        }
    }
]

See also