Creating business unit containers

The following code sample creates a container for business units.

[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 Units' container
$businessUnitsPath = $service.Backend.GetConfigurationContainerPath(
    "BusinessUnits")
$businessUnitsContainer = $service.OpenObject($businessUnitsPath,
    $null, $null, 0)

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

The following code sample creates a business unit 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
$businessUnitsPath = $service.Backend.GetConfigurationContainerPath(
    "BusinessUnits") 
$businessUnitsPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath"`
    $businessUnitsPath
$myContainerPath = $businessUnitsPathObj.CreateChildPath("CN=My Container")
$myContainer = $service.OpenObject($myContainerPath, $null, $null, 0)

# Create business unit
$myBusinessUnit = $myContainer.Create("adm-BusinessUnit", "CN=My Unit")
$myBusinessUnit.Description = "My description"

# [TODO] specify membership rules

$myBusinessUnit.SetInfo()

For information on how to define membership rules for a business unit, see Modifying membership rules.

See also