Script Repository


Get custom value stored in Adaxes configuration

February 14, 2018
1738

To enable storing of data for which there are no Active Directory attributes, Adaxes provides custom attributes of AD objects, such as, for example, CustomAttributeText1 or CustomAttributeInt1. The attributes are stored at Adaxes Configuration Server (AD LDS) and can be used with any Active Directory objects, such as users, groups, containers etc.

Adaxes service configuration is also stored on the configuration server in a directory container. Its custom attributes can also be used to store data. For example, it can store the last employee number assigned to a user in order to quickly assign the next one in sequence when creating the next user account.

For information on how to save a value in Adaxes configuration container, see Store data in Adaxes configuration.

This script outputs a numeric value stored in an attribute of the Adaxes configuration container. To use the code, create a Custom Command for Domain-DNS objects that runs the script and execute it on any of your AD domains. The value is added to the Execution Log of the operation that is displayed after the command completes.

Parameters:

See Also: Create object names in sequential order.
Edit Remove
PowerShell
$queryPropertyName = "adm-CustomAttributeInt1" # TODO: modify me
$stringFomrat = "PC-{0:000}" # TODO: modify me

# Get the number stored in the global configuration
$adaxesSettingsPath = $Context.GetWellKnownContainerPath("ConfigurationSetSettings")
$adaxesSettings = $Context.BindToObject($adaxesSettingsPath)

try
{
    $value = [int]($settings.Get($queryPropertyName))
}
catch
{
    $Context.LogMessage("The requested property is not assigned a value.", "Warning")
    return
}

$valueOutput = [System.String]::Format($stringFomrat, $value)
$Context.LogMessage("Property value: $valueOutput", "Information")


Comments ( 2 )
avatar
Jason
Oct 06, 2020
Can a custom value stored in Adaxes configuration be referenced in a parameter?

For example I have my own script to generate pass phrases from a dictionary. Every time a custom command is run to reset a password (instead of the default reset password action) I have the pass phrase generator script run and generate a new passphrase for the next password reset.

Id like the Passphrase parameter to use the passphrase that is stored in the Adaxes configuration as the Default Value for the parameter.
avatar
Support
Oct 06, 2020
Hello Jason,

You can use this script in a Scheduled task to get the value and then set it as default in a Custom Command parameter. Unfortunately, there is no possibility to make the value always be present in the parameter settings dynamically. If you have issues modifying the script accordingly, we will help you.
Leave a comment