Skip to content

Enumerating user accounts

The following code sample enumerates user accounts located in a specific Organizational 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 the Organizational Unit
$containerDN = "CN=Users,DC=domain,DC=com"
$container = $admService.OpenObject("Adaxes://$containerDN", $NULL, $NULL, 0)

$container.Filter = @("user")

foreach ($user in $container)
{
    Write-Host $user.Get("cn")
}
Import-Module Adaxes

$containerDN = "CN=Users,DC=domain,DC=com"

$users = Get-AdmUser -Filter * -SearchBase $containerDN  `
    -SearchScope OneLevel -Server "domain.com" -AdaxesService localhost 

foreach ($user in $users)
{
    Write-Host $user.Name
}

See also