Script Repository

Add new allowed property value to a Property Pattern

September 24, 2020

The script adds a new value to the list of values allowed for a property by a Property Pattern and sorts all the values in alphabetical order. To run the script, create a Custom Command configured for the Domain-DNS object type. The value to be added is taken from the Custom Command parameter.


  • $propertyName - Specifies the LDAP name of the property for which a new value will be added.
  • $propertyPatternDN - Specifies the distinguished name (DN) of the Proeprty Pattern to be updated. For information on how to get the DN of a directory object, see Get the DN of an Active Directory object.
  • $parameterName - Specifies the name of the Custom Command parameter that will be used to enter the value to be added with the param- prefix.
Edit Remove
$propertyName = "company" # TODO: modify me
$propertyPatternDN = "CN=My Pattern,CN=Property Patterns,CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes" # TODO: modify me
$parameterName = "param-Value" # TODO: modify me

# Get parameter value
$parameterValue = $Context.GetParameterValue($parameterName)

# Bind to the Property Pattern
$userPattern = $Context.BindToObject("Adaxes://$propertyPatternDN")
$values = New-Object System.Collections.ArrayList
$isPropertyRequired = $False
foreach ($item in $userPattern.Items)
    if ($item.PropertyName -ne $propertyName)
    $constraints =  $item.GetConstraints()
    $constraint = $constraints.GetConstraint("ADM_PROPERTYCONSTRAINTCATEGORY_VALUEFORMAT")
    # Check if new value exists
    if ($constraint.Values -contains $parameterValue)

    # Get current values
    $constraint.Values | %%{[void]$values.Add($_)}
    $isPropertyRequired = $item.IsPropertyRequired
    # Remove Property Pattern item

# Add new value

# Sort values

# Update Property Pattern
$item = $userPattern.Items.Create()
$item.PropertyName = $propertyName
$item.IsPropertyRequired = $isPropertyRequired

$constraints = $item.GetConstraints()
$constraint = $constraints.Create("ADM_PROPERTYCONSTRAINTTYPE_VALUERANGE")
$constraint.AreValuesDenied = $False
$constraint.Values = $values.ToArray()

# Save the changes

Comments ( 0 )
No results found.
Leave a comment