Skip to content

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

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

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

Tip

For information on how to define membership rules for a Business Unit, see Modifying membership rules.

See also