Skip to content

Defining the scope of activity for a Business Rule

The following code sample makes a Business Rule effective for all objects in all AD domains managed by Adaxes.

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

# Connect to the Adaxes service
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")

# Bind to 'My Rule' Business Rule
$businessRulesPath = $admService.Backend.GetConfigurationContainerPath(
    "BusinessRules")
$businessRulesPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath" `
    $businessRulesPath
$myRuleAdsPath = $businessRulesPathObj.CreateChildPath( `
    "CN=My Rule")
$rule = $admService.OpenObject($myRuleAdsPath, $NULL, $NULL, 0)

$scopeItem = $rule.ActivityScopeItems.Create()
$scopeItem.BaseObject = $NULL
$scopeItem.Type = "ADM_SCOPEBASEOBJECTTYPE_ALL_DIRECTORY"
$scopeItem.Inheritance = "ADS_SCOPE_SUBTREE"
$scopeItem.Exclude = $False
$scopeItem.SetInfo()

$rule.ActivityScopeItems.Add($scopeItem)

The following code sample makes a Business Rule effective for all objects in a specific Active Directory domain.

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

# Connect to the Adaxes service
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")

# Bind to 'My Rule' Business Rule
$businessRulesPath = $admService.Backend.GetConfigurationContainerPath(
    "BusinessRules")
$businessRulesPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath" `
    $businessRulesPath
$myBusinessRuleAdsPath = $businessRulesPathObj.CreateChildPath( `
    "CN=My Rule")
$rule = $admService.OpenObject($myBusinessRuleAdsPath, $NULL, $NULL, 0)

$domain = "example.com"
$domainObj = $admService.OpenObject("Adaxes://$domain", $NULL, $NULL, 0)

$scopeItem = $rule.ActivityScopeItems.Create()
$scopeItem.BaseObject = $domainObj
$scopeItem.Type = "ADM_SCOPEBASEOBJECTTYPE_CONTAINER"
$scopeItem.Inheritance = "ADS_SCOPE_SUBTREE"
$scopeItem.Exclude = $False
$scopeItem.SetInfo()

$rule.ActivityScopeItems.Add($scopeItem)

The following code sample makes a Business Rule effective for all objects located in an Organizational Unit.

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

# Connect to the Adaxes service
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")

# Bind to 'My Rule' Business Rule
$businessRulesPath = $admService.Backend.GetConfigurationContainerPath(
    "BusinessRules")
$businessRulesPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath" `
    $businessRulesPath
$myBusinessRuleAdsPath = $businessRulesPathObj.CreateChildPath( `
    "CN=My Rule")
$rule = $admService.OpenObject($myBusinessRuleAdsPath, $NULL, $NULL, 0)

$ouDN = "OU=Sales,DC=domain,DC=com"
$ou = $admService.OpenObject("Adaxes://$ouDN", $NULL, $NULL, 0)

$scopeItem = $rule.ActivityScopeItems.Create()
$scopeItem.BaseObject = $ou
$scopeItem.Type = "ADM_SCOPEBASEOBJECTTYPE_CONTAINER"
$scopeItem.Inheritance = "ADS_SCOPE_SUBTREE"
$scopeItem.Exclude = $False
$scopeItem.SetInfo()

$rule.ActivityScopeItems.Add($scopeItem)

The following code sample makes a Business Rule effective for all members of a specific group.

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

# Connect to the Adaxes service
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")

# Bind to 'My Rule' Business Rule
$businessRulesPath = $admService.Backend.GetConfigurationContainerPath(
    "BusinessRules")
$businessRulesPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath" `
    $businessRulesPath
$myBusinessRuleAdsPath = $businessRulesPathObj.CreateChildPath( `
    "CN=My Rule")
$rule = $admService.OpenObject($myBusinessRuleAdsPath, $NULL, $NULL, 0)

$groupDN = "CN=My Group,DC=domain,DC=com"
$groupObj = $admService.OpenObject("Adaxes://$groupDN", $NULL, $NULL, 0)

$scopeItem = $rule.ActivityScopeItems.Create()
$scopeItem.BaseObject = $groupObj
$scopeItem.Type = "ADM_SCOPEBASEOBJECTTYPE_GROUP"
$scopeItem.Inheritance = "ADS_SCOPE_SUBTREE"
$scopeItem.Exclude = $False
$scopeItem.SetInfo()

$rule.ActivityScopeItems.Add($scopeItem)

The following code sample makes a Business Rule effective for all members of a specific Business Unit.

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

# Connect to the Adaxes service
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")

# Bind to 'My Rule' Business Rule
$businessRulesPath = $admService.Backend.GetConfigurationContainerPath(
    "BusinessRules")
$businessRulesPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath" `
    $businessRulesPath
$myBusinessRuleAdsPath = $businessRulesPathObj.CreateChildPath( `
    "CN=My Rule")
$rule = $admService.OpenObject($myBusinessRuleAdsPath, $NULL, $NULL, 0)

$businessUnitsPath = $admService.Backend.GetConfigurationContainerPath( `
    "BusinessUnits")
$businessUnitsPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath" `
    $businessUnitsPath
$myBusinessUnitPath = $businessUnitsPathObj.CreateChildPath( `
    "CN=My BusinessUnit")

$businessUnitObj = $admService.OpenObject($myBusinessUnitPath, $NULL, $NULL, 0)

$scopeItem = $rule.ActivityScopeItems.Create()
$scopeItem.BaseObject = $businessUnitObj
$scopeItem.Type = "ADM_SCOPEBASEOBJECTTYPE_BUSINESSUNIT"
$scopeItem.Inheritance = "ADS_SCOPE_SUBTREE"
$scopeItem.Exclude = $False
$scopeItem.SetInfo()

$rule.ActivityScopeItems.Add($scopeItem)

The following code sample makes a Business Rule effective for a specific AD object.

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

# Connect to the Adaxes service
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")

# Bind to 'My Rule' Business Rule
$businessRulesPath = $admService.Backend.GetConfigurationContainerPath(
    "BusinessRules")
$businessRulesPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath" `
    $businessRulesPath
$myBusinessRuleAdsPath = $businessRulesPathObj.CreateChildPath( `
    "CN=My Rule")
$rule = $admService.OpenObject($myBusinessRuleAdsPath, $NULL, $NULL, 0)

$ouDN = "OU=Sales,DC=domain,DC=com"
$ouObj = $admService.OpenObject("Adaxes://$ouDN", $NULL, $NULL, 0)

$scopeItem = $rule.ActivityScopeItems.Create()
$scopeItem.BaseObject = $ouObj
$scopeItem.Type = "ADM_SCOPEBASEOBJECTTYPE_CONTAINER"
$scopeItem.Inheritance = "ADS_SCOPE_BASE"
$scopeItem.Exclude = $False
$scopeItem.SetInfo()

$rule.ActivityScopeItems.Add($scopeItem)

See also