Skip to content

Getting Business Unit members

The following code sample retrieves a list of all the members of a 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 'My Unit' Business Unit
$businessUnitsPath = $admService.Backend.GetConfigurationContainerPath(
    "BusinessUnits")
$businessUnitsPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath" `
    $businessUnitsPath
$myBusinessUnitAdsPath = $businessUnitsPathObj.CreateChildPath( `
    "CN=My Unit")

$myBusinessUnit = $admService.OpenObject($myBusinessUnitAdsPath, $NULL, $NULL, 0)

$members = $myBusinessUnit.Members()

for ($i = 0; $i -lt $members.Count; $i++)
{
    $member = $members.GetObject($i)
    Write-Host $member.Get("name")
}

See also