Enumerating user accounts
The following code sample enumerates user accounts located in a specific organizational unit.
- ADSI
-
[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 organizational unit $containerDN = "CN=Users,DC=domain,DC=com" $container = $service.OpenObject("Adaxes://$containerDN", $null, $null, 0) $container.Filter = @("user") foreach ($user in $container) { Write-Host $user.Get("cn") }
- PowerShell
-
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 }