Function ObjectsInOU(OPTIONAL $OU, OPTIONAL $filter)
Dim $f[0],$objs[0],$x,$objADsPath,$obj
If not $OU
$OU = GetObject("LDAP://"+CreateObject("ADSystemInfo").ComputerName).Parent
If @Error
Exit @Error
Endif
Endif
$objADsPath = GetObject($OU)
If @Error = 0
If $filter
$f[0] = $filter
$objAdsPath.filter = $f
Endif
$x = 0
For Each $obj In $objAdsPath
If $filter="user"
If $obj.Class="User"
$objs[$x] = Split($obj.Name,"=")[1]
$x = 1+$x
ReDim Preserve $objs[$x]
Endif
Else
$objs[$x] = Split($obj.Name,"=")[1]
$x = 1+$x
ReDim Preserve $objs[$x]
Endif
Next
If UBound($objs) > 0
ReDim Preserve $objs[UBound($objs)-1]
Endif
$ObjectsInOU = $objs
Else
Exit @Error
Endif
EndFunction