Skip to content

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

# Bind to the 'Business Rules' container
$businessRulesPath = $admService.Backend.GetConfigurationContainerPath(
    "BusinessRules")
$businessRulesContainer = $admService.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
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")

# Bind to the 'My Container' container
$businessRulesPath = $admService.Backend.GetConfigurationContainerPath(
    "BusinessRules")
$businessRulesPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath"`
    $businessRulesPath
$myContainerPath = $businessRulesPathObj.CreateChildPath("CN=My Container")
$myContainer = $admService.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