Deleting business units

The following code sample deletes a 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 business unit
$businessUnitsPath = $service.Backend.GetConfigurationContainerPath("BusinessUnits")
$businessUnitsPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath" $businessUnitsPath
$myBusinessUnitAdsPath = $businessUnitsPathObj.CreateChildPath("CN=My Unit")

$myBusinessUnit = $service.OpenObject($myBusinessUnitAdsPath, $null, $null, 0)

# Delete the business unit
$myBusinessUnit.DeleteObject("ADM_DELETEOBJECTFLAGS_AUTO")

See also