Script Repository


Get custom value stored in Adaxes configuration

February 24, 2021
2395

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 ( 4 )
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.
avatar
Jason Moodie
Oct 27, 2020
I have scripted the change of the default value as suggested which seems to work well however after the default value is changed the default value does not update on the web interface until a complete page refresh is completed. A standard page refresh doesn't update it either. Any ideas on how to stop the parameter from being cached?
avatar
Support
Oct 28, 2020
Hello Jason,

Sorry for the confusion, but we are not sure what exactly you mean. The thing is that the property value is set for the Adaxes Configuration container which is not available in the UI. Please, provide us with all the possible details about the behavior including the scripts you have. You can send the details to our support email: support[at]adaxes.com.
Leave a comment