Skip to content

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
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")

# Bind to the 'Property Patterns' container
$propertyPatternsPath = $admService.Backend.GetConfigurationContainerPath(
    "PropertyPatterns")
$propertyPatternsContainer = $admService.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