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
$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)

$members = $myBusinessUnit.Members()

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

See also