Hello,
Thank you for the confirmation. To add values via a Custom Command, you can use the following script from our repository: https://www.adaxes.com/script-repository/add-new-allowed-property-value-to-a-property-pattern-s585.htm.
To add values via Windows PowerShell, you can use the script below:
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")
$propertyName = "title" # TODO: modify me
$propertyPatternDN = "CN=My Pattern,CN=Property Patterns,CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes" # TODO: modify me
# Get value
$value = Read-Host "Specify the value to add"
# Connect to the Adaxes service
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")
# Bind to the Property Pattern
$userPattern = $admService.OpenObject("Adaxes://$propertyPatternDN", $NULL, $NULL, 0)
$values = New-Object System.Collections.ArrayList
$isPropertyRequired = $False
foreach ($item in $userPattern.Items)
{
if ($item.PropertyName -ne $propertyName)
{
continue
}
$constraints = $item.GetConstraints()
$constraint = $constraints.GetConstraint("ADM_PROPERTYCONSTRAINTCATEGORY_VALUEFORMAT")
# Check if new value exists
if ($constraint.Values -contains $value)
{
return
}
# Get current values
$constraint.Values | %{[void]$values.Add($_)}
$isPropertyRequired = $item.IsPropertyRequired
# Remove Property Pattern item
$userPattern.Items.Remove($item)
break
}
# Add new value
[void]$values.Add($value)
# Sort values
$values.Sort()
# 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()
$constraints.Add($constraint)
$item.SetConstraints($constraints)
# Save the changes
$item.SetInfo()
$userPattern.Items.Add($item)
In the script:
- $propertyName – Specifies the LDAP name of the property for which a new value will be added.
- $propertyPatternDN – Specifies the distinguished name (DN) of the Property 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.
When prompted, enter the value to be added to the list of allowed ones.