Modifying property patterns
The following code sample modifies a built-in property pattern, User. The script specifies a list of possible values for the Department property of user accounts.
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")
# Connect to the Adaxes service
$ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$service = $ns.GetServiceDirectly("localhost")
# Bind to the property pattern
$propertyPatternsPath = $service.Backend.GetConfigurationContainerPath(
"PropertyPatterns")
$propertyPatternsPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath" `
$propertyPatternsPath
$builtinPathObj = $propertyPatternsPathObj.CreateChildPath("CN=Builtin")
$userPatternPath = $builtinPathObj.CreateChildPath("CN=User")
$userPattern = $service.OpenObject($userPatternPath.ToString(),
$null, $null, 0)
# Delete the item for the 'Department' property
foreach ($item in $userPattern.Items)
{
if ($item.PropertyName -ieq "department")
{
$userPattern.Items.Remove($item)
break
}
}
$item = $userPattern.Items.Create()
$item.PropertyName = "department"
$constraints = $item.GetConstraints()
$constraint = $constraints.Create(
"ADM_PROPERTYCONSTRAINTTYPE_VALUERANGE")
$constraint.AreValuesDenied = $false
$constraint.Values = @("IT", "HR", "Sales")
$constraints.Add($constraint)
$item.SetConstraints($constraints)
$item.SetInfo()
$userPattern.Items.Add($item)
See also
- Managing property patterns
- Binding to Adaxes-specific objects
- Managing Adaxes-specific objects
- IADs
- IAdmPropertyPattern
- IAdmPropertyPatternItem
- IAdmValueRangeConstraint
- Online script repository