Skip to content

Defining the scope of activity for a Property Pattern

The following code sample makes a Property Pattern 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 the 'My Pattern' Property Pattern
$propertyPatternsPath = $admService.Backend.GetConfigurationContainerPath(
    "PropertyPatterns")
$propertyPatternsPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath" `
    $propertyPatternsPath
$propertyPatternAdsPath = $propertyPatternsPathObj.CreateChildPath( `
    "CN=My Pattern")
$myPropertyPattern = $admService.OpenObject($propertyPatternAdsPath, $NULL, $NULL, 0)

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

$myPropertyPattern.ActivityScopeItems.Add($scopeItem)

The following code sample makes a Property Pattern 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 the 'My Pattern' Property Pattern
$propertyPatternsPath = $admService.Backend.GetConfigurationContainerPath(
    "PropertyPatterns")
$propertyPatternsPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath" `
    $propertyPatternsPath
$propertyPatternAdsPath = $propertyPatternsPathObj.CreateChildPath( `
    "CN=My Pattern")
$myPropertyPattern = $admService.OpenObject($propertyPatternAdsPath, $NULL, $NULL, 0)

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

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

$myPropertyPattern.ActivityScopeItems.Add($scopeItem)

The following code sample makes a Property Pattern 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 the 'My Pattern' Property Pattern
$propertyPatternsPath = $admService.Backend.GetConfigurationContainerPath(
    "PropertyPatterns")
$propertyPatternsPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath" `
    $propertyPatternsPath
$propertyPatternAdsPath = $propertyPatternsPathObj.CreateChildPath( `
    "CN=My Pattern")
$myPropertyPattern = $admService.OpenObject($propertyPatternAdsPath, $NULL, $NULL, 0)

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

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

$myPropertyPattern.ActivityScopeItems.Add($scopeItem)

The following code sample makes a Property Pattern 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 the 'My Pattern' Property Pattern
$propertyPatternsPath = $admService.Backend.GetConfigurationContainerPath(
    "PropertyPatterns")
$propertyPatternsPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath" `
    $propertyPatternsPath
$propertyPatternAdsPath = $propertyPatternsPathObj.CreateChildPath( `
    "CN=My Pattern")
$myPropertyPattern = $admService.OpenObject($propertyPatternAdsPath, $NULL, $NULL, 0)

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

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

$myPropertyPattern.ActivityScopeItems.Add($scopeItem)

The following code sample makes a Property Pattern 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 the 'My Pattern' Property Pattern
$propertyPatternsPath = $admService.Backend.GetConfigurationContainerPath(
    "PropertyPatterns")
$propertyPatternsPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath" `
    $propertyPatternsPath
$propertyPatternAdsPath = $propertyPatternsPathObj.CreateChildPath( `
    "CN=My Pattern")
$myPropertyPattern = $admService.OpenObject($propertyPatternAdsPath, $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 = $myPropertyPattern.ActivityScopeItems.Create()
$scopeItem.BaseObject = $businessUnitObj
$scopeItem.Type = "ADM_SCOPEBASEOBJECTTYPE_BUSINESSUNIT"
$scopeItem.Inheritance = "ADS_SCOPE_SUBTREE"
$scopeItem.Exclude = $False
$scopeItem.SetInfo()

$myPropertyPattern.ActivityScopeItems.Add($scopeItem)

See also