Sorry, search feature is not supported in Internet Explorer 11

Get business unit members

Retrieves all members of a business unit.

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

Query parameters

  • Name

  • Required

  • Type

  • Description

  • businessUnit

  • True

  • string

  • The identifier of the business unit whose members to retrieve. A business unit can be identified by:

     Distinguished name (DN) {.black}
    # 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) {.black}
    # 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 LDAP 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 {.black}
    • guid
    • dn
    • displayName
    • objectType
    • objectTypeCode
    • domainName
  • sizeLimit

  • False

  • integer

  • The maximum number of objects to be retrieved. If not specified, defaults to 1000.

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.

Tip

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
$unitIdentifier = "CN=My Unit,CN=Business Units,CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes"

$baseUrl = "https://host.example.com/restApi"
$endpoint = "/api/directoryObjects/businessUnitMembers"
$requestUrl = $baseUrl + $endpoint
$requestHeaders = @{"Adm-Authorization" = "HxtdAPz73OFfae7....w7lQvxjJHIbVqgkCtPtLD"}
$requestParams = @{businessUnit = $unitIdentifier}

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

class Program
{
    static async Task Main()
    {
        string unitIdentifier = "CN=My Unit,CN=Business Units,CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes";
        const string token = "HxtdAPz73OFfae7....w7lQvxjJHIbVqgkCtPtLD";

        UriBuilder requestUrl = new UriBuilder(
            "https://host.example.com/restApi/api/directoryObjects/businessUnitMembers");
        requestUrl.Query += $"?businessUnit={unitIdentifier}";

        // Initialize HTTP client
        using (HttpClient client = new HttpClient())
        {
            client.DefaultRequestHeaders.Add("Adm-Authorization", token);

            // Make request
            string response = await client.GetStringAsync(requestUrl.ToString());
            Console.WriteLine(response);
        }
    }
}
cURL
curl  --header 'Adm-Authorization: HxtdAPz73OFfae7....w7lQvxjJHIbVqgkCtPtLD' \
--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 unitIdentifier = "CN=My Unit,CN=Business Units,CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes";

var https = require("https");

// Request parameters and headers
var requestPath = "/restApi/api/directoryObjects/businessUnitMembers"
    + `?businessUnit=${unitIdentifier}`;
    
var options = {
    'method': 'GET',
    'hostname': 'host.example.com',
    'path': encodeURI(requestPath),
    'headers': {
        "Adm-Authorization": "HxtdAPz73OFfae7....w7lQvxjJHIbVqgkCtPtLD",
    }
};

// Make request
var req = https.request(options, function (res) {
    var chunks = [];

    res.on("data", function (chunk) {
        chunks.push(chunk);
    });

    res.on("end", function (chunk) {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
    });

    res.on("error", function (error) {
        console.error(error);
    });
});

req.end();

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",
        "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",
        "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
$unitIdentifier = "CN=My Unit,CN=Business Units,CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes"
$propertiesToGet = "department,accountExpires"

$baseUrl = "https://host.example.com/restApi"
$endpoint = "/api/directoryObjects/businessUnitMembers"
$requestUrl = $baseUrl + $endpoint
$requestHeaders = @{"Adm-Authorization" = "HxtdAPz73OFfae7....w7lQvxjJHIbVqgkCtPtLD"}
$requestParams = @{
    businessUnit = $unitIdentifier;
    properties = $propertiesToGet
}

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

class Program
{
    static async Task Main()
    {
        string unitIdentifier = "CN=My Unit,CN=Business Units,CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes";
        const string propertiesToGet = "department,accountExpires";
        const string token = "HxtdAPz73OFfae7....w7lQvxjJHIbVqgkCtPtLD";

        UriBuilder requestUrl = new UriBuilder(
            "https://host.example.com/restApi/api/directoryObjects/businessUnitMembers");
        requestUrl.Query += $"?businessUnit={unitIdentifier}";
        requestUrl.Query += $"&properties={propertiesToGet}";

        // Initialize HTTP client
        using (HttpClient client = new HttpClient())
        {
            client.DefaultRequestHeaders.Add("Adm-Authorization", token);

            // Make request
            string response = await client.GetStringAsync(requestUrl.ToString());
            Console.WriteLine(response);
        }
    }
}
cURL
curl  --header 'Adm-Authorization: HxtdAPz73OFfae7....w7lQvxjJHIbVqgkCtPtLD' \
--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 unitIdentifier = encodeURIComponent("CN=My Unit,CN=Business Units,CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes");
var propertiesToGet = "department,accountExpires";

var https = require("https");

// Request parameters and headers
var requestPath = "/restApi/api/directoryObjects/businessUnitMembers"
    + `?businessUnit=${unitIdentifier}`
    + `&properties=${propertiesToGet}`;
    
var options = {
    'method': 'GET',
    'hostname': 'host.example.com',
    'path': requestPath,
    'headers': {
        "Adm-Authorization": "HxtdAPz73OFfae7....w7lQvxjJHIbVqgkCtPtLD",
    }
};

// Make request
var req = https.request(options, function (res) {
    var chunks = [];

    res.on("data", function (chunk) {
        chunks.push(chunk);
    });

    res.on("end", function (chunk) {
        var body = Buffer.concat(chunks);
        console.log(body.toString());
    });

    res.on("error", function (error) {
        console.error(error);
    });
});

req.end();

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",
        "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",
        "properties": {
            "department": [
                "Marketing"
            ],
            "accountexpires": [
                "2021-02-03T14:19:38.9936927Z"
            ]
        }
    }
]

See also