Break ON
$gNull=SetOption("ASCII","ON")
$gNull=SetOption("WrapAtEOL","ON")
$gNull=SetOption("Explicit","ON")
; GETU.KIX
; -----------------
;
; Iterate all user objects in an OU
Dim $sUser,$sOU
Dim $objConnection,$objCommand,$sSearchBase,$objRecordSet
$objConnection = CreateObject("ADODB.Connection")
$objCommand = CreateObject("ADODB.Command")
$objConnection.Provider = "ADsDSOObject"
$objConnection.Open("Active Directory Provider")
$objCommand.ActiveConnection = $objConnection
$sSearchBase="ou=some_ou,dc=subdomain,dc=domain,dc=tld"
$objCommand.CommandText =
"SELECT Name,distinguishedName FROM "
+ "'LDAP://"+$sSearchBase
+ "'"
+ " WHERE objectCategory='user'"
$objCommand.Properties("Page Size").Value = 100
$objCommand.Properties("Search Scope").Value = 2
$objCommand.Properties("Cache Results").Value = (not 1)
$objRecordSet = $objCommand.Execute()
$objRecordSet.MoveFirst
while not $objRecordSet.EOF
$sUser=$objRecordSet.Fields("Name").Value
$sOU=$objRecordSet.Fields("distinguishedName").Value
Left($sUser+" ",30)+$sOU+@CRLF
$objRecordSet.MoveNext
Loop
; vim600:ai ts=4 sw=4