Creating business rule containers

The following code sample creates a container for business rules.

[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 'Business Rules' container
$businessRulesPath = $service.Backend.GetConfigurationContainerPath(
    "BusinessRules")
$businessRulesContainer = $service.OpenObject($businessRulesPath,
    $null, $null, 0)

# Create container
$myContainer = $businessRulesContainer.Create("container","CN=My Container")
$myContainer.SetInfo()

The following code sample creates a business rule in a specific container.

[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 'My Container' container
$businessRulesPath = $service.Backend.GetConfigurationContainerPath(
    "BusinessRules")
$businessRulesPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath"`
    $businessRulesPath
$myContainerPath = $businessRulesPathObj.CreateChildPath("CN=My Container")
$myContainer = $service.OpenObject($myContainerPath, $null, $null, 0)

# Create new business rule
$rule = $myContainer.Create("adm-BusinessRule", "CN=My Rule")

$rule.ExecutionMoment = "ADM_BUSINESSRULEEXECMOMENT_AFTER"
$rule.ObjectType = "user"
$rule.OperationType = "create"

$rule.Description = "My description"
$rule.Disabled = $false

# Save the business rule
$rule.SetInfo()

See also