Basically this is a netview for OUs. I think there is more we could do with this, and was kind of looking for some ideas...

Let me know.

code:
Function EnumAD(optional $ou,optional $filter,optional $detaillevel)
Dim $rootdse,$domain,$objects,$container,$OUObject
$rootdse=getobject("LDAP://RootDSE") ;binds rootdse to local ldap object
$domain=$rootdse.get("DefaultNamingContext") ;determines local domain
if $ou<>''
if right($ou,1)<>','
$ou=$ou + ','
endif
endif
$container="LDAP://" + $ou + $domain
$ouobjects = GetObject($container)
select
case ucase($filter)="ORGANIZATIONALUNIT"
$ouobjects.Filter = "OrganizationalUnit","_"
case ucase($filter)="COMPUTER"
$ouobjects.Filter = "computer","_"
case ucase($filter)="GROUP"
$ouobjects.Filter = "group","_"
case ucase($filter)="USER"
$ouobjects.Filter = "user","_"
endselect
For Each $OUObject in $ouobjects
if $objects<>""
$objects=$objects + '|'
endif
select
case $detaillevel=2
if ucase($filter)="USER"
If $OUObject.Class = "user"
$objects=$objects + ucase($OUObject.ADSPath)
endif
else
$objects=$objects + ucase($OUObject.ADSPath)
endif

case $detaillevel=1
if ucase($filter)="USER"
If $OUObject.Class = "user"
$objects=$objects + ucase($OUObject.Name)
endif
else
$objects=$objects + ucase($OUObject.Name)
endif

case 1
if ucase($filter)="USER"
If $OUObject.Class = "user"
$objects=$objects + ucase(substr($OUObject.Name,4))
endif
else
$objects=$objects + ucase(substr($OUObject.Name,4))
endif
endselect
Next
$EnumAD=split($objects,'|')
Endfunction

Here is a simple example:

break on
$ouroot="ou=adtest"
dim $ou
$OUs=EnumAD($ouroot,"OrganizationalUnit",1)
for each $ou in $OUs
for each $computer in EnumAD("$ou,$ouroot","Computer",2)
if $computer<>""
? $computer
endif
next
next

[ 17. May 2003, 05:32: Message edited by: Al_Po ]