Operation result

A JSON representation of the operation execution log. Includes the outcome of the operation, information about triggered business rules, and any warnings or errors that might have occurred during execution.

Attributes

Examples

Success
{
    "resultType": 0,
    "innerMessages": [],
    "exception": null,
    "actualObjectDN": "CN=John Smith,OU=Users,DC=example,DC=com",
    "extraInfo": {}
}
Succeeded with warnings
{
    "resultType": 0,
    "exception": null,
    "innerMessages": [
        {
            "source": null,
            "text": "The password wasn't set because of the 
            following error: Unable to update the password. 
            The value provided for the new password does not 
            meet the length, complexity, or history 
            requirements of the domain. (Server: example.com)
            The password policy requires that the password:
            - must be at least 3 characters.",
            "messageType": 1,
            "innerMessages": []
        },
        {
            "source": null,
            "text": "Property 'userAccountControl' wasn't set because 
            of the following error: Unable to update the password. 
            The value provided for the new password does not meet 
            the length, complexity, or history requirements 
            of the domain. (Server: example.com)",
            "messageType": 1,
            "innerMessages": []
        }
    ],
    "actualObjectDN": "CN=John Smith,CN=Users,DC=example,DC=com",
    "extraInfo": {}
} 
Operation suspended
{
    "resultType": 2,
    "exception": null,
    "innerMessages": [
    {
        "source": "Business Rules",
        "text": "1 rule encountered while processing your request",
        "messageType": 2,
        "innerMessages": [
        {
            "source": "'Business Rule <name>'",
            "text": "Send this operation for approval.",
            "messageType": 3,
            "innerMessages": [
            {
                "source": ',
                "text": "Request submitted for approval.",
                "messageType": 4,
                "innerMessages": []
            }
            ]
        }
        ]
    }
    ],
    "actualObjectDN": "CN=John Smith,CN=Users,DC=example,DC=com",
    "extraInfo": {}
}   
Error
{
    "resultType": 1,
    "exception": {
        "message": "This user doesn't have a mailbox."
    },
    "innerMessages": [],
    "actualObjectDN": "CN=John Smith,CN=Users,DC=example,DC=com",
    "extraInfo": {}
}

resultType enum

The outcome of the operation.

 Show possible enum values
Success     = 0,  // Operation succeeded
Error       = 1,  // Operation failed
Suspended   = 2   // Operation suspended by Adaxes

exception exception

Equals null if the operation succeeded or was suspended. Contains the exception message if the operation failed.


innerMessages OperationResultMessage array

An array of messages from the execution log. Each message can contain more inner messages that follow the same data structure.

 Show attributes

innerMessages.source string

Name of the object source that generated the message. For example, the name of the triggered business rule. This attribute will be empty if there is no defined object source.


innerMessages.text string

Message text.


innerMessages.messageType enum

The type of the returned message.

 Show possible enum values
Error                = 0,  // Error message
Warning              = 1,  // Warning message
Information          = 2,  // Informational message
TriggeredOperation   = 3,  // Business rule was triggered by the operation
ApprovalRequired     = 4   // Main operation or the operation executed by a triggered business rule is sent for approval

innerMessages.innerMessages OperationResultMessage array

An array of nested messages. Each message can contain more inner messages that follow the same data structure.



actualObjectDN string

The distinguished name (DN) of the object the operation was performed on.


extraInfo info

This attribute will have a value only when creating Exchange mailboxes. Contains additional information about the created mailbox.

 Show attributes

extraInfo.mailNickname string

Exchange alias of the mailbox.


extraInfo.mail string

Primary SMTP address of the mailbox.


extraInfo.homeMDB string

The name of the Exchange database where the mailbox was created.


Getting execution log messages

Sometimes, you might need to extract certain information from the execution log and process it further in your code. For example, after executing a custom command via REST API, you might need to obtain the output of $Context.LogMessage from a Run a program or PowerShell script action of that custom command.

The simplest way to do it is to get all messages from the execution log recursively, and take action when you encounter the message you need. The following code sample executes a custom command and outputs all execution log messages into the console in the same order they appear in the log.

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

# Request parameters
$requestUrl = $baseUrl + $endpoint
$requestHeaders = @{"Adm-Authorization" = YOUR-SECURITY-TOKEN}
$requestBody = ConvertTo-Json @{
    "directoryObject" = "CN=John Smith,CN=Users,DC=example,DC=com";
    "customCommandId" = "200778bf-8e3d-4de6-b452-24116a77fde5"
}

# Execute custom command
$response = Invoke-RestMethod -Method POST -Headers $requestHeaders -Uri $requestUrl `
    -Body $requestBody -ContentType "application/json"

# Output log messages to the console
function OutputLogMessages ($logMessage) 
{
    foreach ($innerMessage in $logMessage.innerMessages) 
    {
        # Output message text and get nested messages
        Write-Host $innerMessage.text
        OutputLogMessages $innerMessage       
    }
}

OutputLogMessages $response
C#
using System;
using System.Text;
using System.Net.Http;
using System.Text.Json;
using System.Threading.Tasks;

class Program
{
    /// <summary>
    /// Outputs log messages to the console. 
    /// </summary>
    static void OutputLogMessages(JsonElement logMessage)
    {
        JsonElement innerMessages = logMessage.GetProperty("innerMessages");
        foreach (JsonElement innerMessage in innerMessages.EnumerateArray())
        {
            // Output message text and get nested messages
            Console.WriteLine(innerMessage.GetProperty("text"));
            OutputLogMessages(innerMessage);
        };
    }

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

        // Create JSON request body
        string jsonRequest = @"
        {
            'directoryObject': 'CN=John Smith,CN=Users,DC=example,DC=com',
            'customCommandId': '200778bf-8e3d-4de6-b452-24116a77fde5'
        }";
        StringContent requestBody = new(jsonRequest, Encoding.UTF8, "application/json");

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

        // Execute custom command
        HttpResponseMessage response = await client.PostAsync(
            baseUrl + endpoint, requestBody);
        string responseBody = response.Content.ReadAsStringAsync().Result;

        // Get execution log messages
        using JsonDocument doc = JsonDocument.Parse(responseBody);
        OutputLogMessages(doc.RootElement);
    }
}
node.js
var https = require('http');

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

// Create JSON request body
var postData = `
{
    "directoryObject": "CN=John Smith,CN=Users,DC=example,DC=com",
    "customCommandId": "200778bf-8e3d-4de6-b452-24116a77fde5"
}`;

// Outputs log messages to the console
function OutputLogMessages(logMessage)
{
    (logMessage.innerMessages).forEach(innerMessage => {
        // Output message text and get nested messages
        console.log(innerMessage.text)
        OutputLogMessages(innerMessage);
    }); 
}

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

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

    res.on("end", () => {
        parsedData = JSON.parse(Buffer.concat(data))

        // Get execution log messages
        OutputLogMessages(parsedData);
    });

    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/executeCustomCommand"

# Request parameters
requestUrl = baseUrl + endpoint
requestHeaders = {"Adm-Authorization": YOUR-SECURITY-TOKEN}
requestBody = {
    "directoryObject": "CN=John Smith,CN=Users,DC=example,DC=com",
    "customCommandId": "200778bf-8e3d-4de6-b452-24116a77fde5"
}

# Execute custom command
request = requests.post(requestUrl, headers=requestHeaders, json=requestBody)
response = json.loads(request.content)

# Outputs log messages to the console
def OutputLogMessages(logMessage):
    for innerMessage in logMessage["innerMessages"]:
        # Output message text and get nested messages
        print(innerMessage["text"])
        OutputLogMessages(innerMessage)

OutputLogMessages(response)