Defining the scope of activity for a property pattern
The following code sample makes a property pattern effective for all objects in all the domains managed by Adaxes.
[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 property pattern
$propertyPatternsPath = $service.Backend.GetConfigurationContainerPath(
"PropertyPatterns")
$propertyPatternsPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath" `
$propertyPatternsPath
$propertyPatternAdsPath = $propertyPatternsPathObj.CreateChildPath( `
"CN=My Pattern")
$myPropertyPattern = $service.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 domain.
[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 property pattern
$propertyPatternsPath = $service.Backend.GetConfigurationContainerPath(
"PropertyPatterns")
$propertyPatternsPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath" `
$propertyPatternsPath
$propertyPatternAdsPath = $propertyPatternsPathObj.CreateChildPath( `
"CN=My Pattern")
$myPropertyPattern = $service.OpenObject($propertyPatternAdsPath, $null, $null, 0)
$domain = "example.com"
$domainObj = $service.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
$ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$service = $ns.GetServiceDirectly("localhost")
# Bind to the property pattern
$propertyPatternsPath = $service.Backend.GetConfigurationContainerPath(
"PropertyPatterns")
$propertyPatternsPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath" `
$propertyPatternsPath
$propertyPatternAdsPath = $propertyPatternsPathObj.CreateChildPath( `
"CN=My Pattern")
$myPropertyPattern = $service.OpenObject($propertyPatternAdsPath, $null, $null, 0)
$ouDN = "OU=Sales,DC=example,DC=com"
$ou = $service.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
$ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$service = $ns.GetServiceDirectly("localhost")
# Bind to the property pattern
$propertyPatternsPath = $service.Backend.GetConfigurationContainerPath(
"PropertyPatterns")
$propertyPatternsPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath" `
$propertyPatternsPath
$propertyPatternAdsPath = $propertyPatternsPathObj.CreateChildPath( `
"CN=My Pattern")
$myPropertyPattern = $service.OpenObject($propertyPatternAdsPath, $null, $null, 0)
$groupDN = "CN=My Group,DC=example,DC=com"
$groupObj = $service.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
$ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$service = $ns.GetServiceDirectly("localhost")
# Bind to the property pattern
$propertyPatternsPath = $service.Backend.GetConfigurationContainerPath(
"PropertyPatterns")
$propertyPatternsPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath" `
$propertyPatternsPath
$propertyPatternAdsPath = $propertyPatternsPathObj.CreateChildPath( `
"CN=My Pattern")
$myPropertyPattern = $service.OpenObject($propertyPatternAdsPath, $null, $null, 0)
$businessUnitsPath = $service.Backend.GetConfigurationContainerPath( `
"BusinessUnits")
$businessUnitsPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath" `
$businessUnitsPath
$myBusinessUnitPath = $businessUnitsPathObj.CreateChildPath( `
"CN=My BusinessUnit")
$businessUnitObj = $service.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
- Defining the scope of activity
- Managing property patterns
- Binding to Adaxes-specific objects
- Managing Adaxes-specific objects
- IAdmPropertyPattern
- IAdmActivityScopeItem
- IAdmCollection
- Online script repository