Creating property patterns

The following code sample creates a property pattern. The pattern will mark the Description property of user accounts as required.

[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 Patterns' container
$propertyPatternsPath = $service.Backend.GetConfigurationContainerPath(
    "PropertyPatterns")
$propertyPatternsContainer = $service.OpenObject($propertyPatternsPath,
    $null, $null, 0)

# Create new property pattern
$pattern = $propertyPatternsContainer.Create("adm-PropertyPattern",
    "CN=My Pattern")

$pattern.ObjectType = "user"
$pattern.Description = "My description"
$pattern.Disabled = $false

$pattern.SetInfo()

$item = $pattern.Items.Create()
$item.PropertyName = "description"
$item.IsPropertyRequired = $true

$item.SetInfo()
$pattern.Items.Add($item)

See also