Script repository

Preserve user creation initiator

Updated on: Jan 18, 2026, Views: 533

User accounts

The script saves the initiator of the target user creation to a predefined property. To execute the script, create a custom command configured for the required object type.

In the script, the $initiatorPropertyName variable specifies the schema name of the DN-syntax property to preserve user creaton initiator in. If the target object was created outside Adaxes, the property will be cleared.

$initiatorPropertyName = "adm-CustomAttributeObject1" # TODO: modify me

# Get user modification log.
$modificationLog = $Context.TargetObject.GetModificationLog()
$log = $modificationLog.Log
$records = $log.GetPage(0)

foreach ($record in $records)
{
    $operationTypes = $record.GetOperationTypes()
    if ($operationTypes -notcontains "create")
    {
        continue
    }

    try
    {
        # Get initiator DN.
        $initiator = $Context.BindToObject($record.Initiator.AdsPath)
        $initiatorDN = $initiator.Get("distinguishedName")
    }
    catch
    {
        $initiatorDN = $NULL
    }
    
    break
}

# Save changes
$Context.TargetObject.Put($initiatorPropertyName, $initiatorName)
$Context.TargetObject.SetInfo()

Comments 0

You must be signed in to comment.

    Got questions?

    Support Questions & Answers

    We use cookies to improve your experience.
    By your continued use of this site you accept such use.
    For more details please see our privacy policy and cookies policy.