There seems to be a problem with the IADsContainer FILTER property. In this function the filter works properly for "group", "computer", and "container", but returns computer objects of both 'user' and 'computer' classes when the FILTER is set to "user". This may be related to the fact that computer accounts are indeed hidden user account "computer$", but that should not be the issue since the object definitely return the class "computer" when the FILTER is to "user".

I have added additional code to validate that the object class is indeed the specified and desired class of object the function was sent to enumerate. See the "if $Class = $Filter" construct.

Also I have an oversight when enumerating the complete domain for users. The object called "Users" is in fact of class "container". So the code was modified to recurse on objects of both classes: 'organizationalUnit' and 'container'. The $aFilter array was Redim'ed and the extra filter added.


Function EnumOUs($LDAP, $Filter)
;$Filter = 'computer' | 'user' | 'group'
dim $aFilter[0], $pos, $objOU, $i, $j, $Class
$i = 0
$j = 0
$aFilter[0] = $Filter

$objOU = GetObject($LDAP)
if VarTypeName($objOU)='Object'
? ucase(Left($Filter,1)) + substr($Filter,2) + "(s) in ($LDAP)"
$objOU.Filter = $aFilter
for each $item in $objOU
$Name = $item.Name
$Class = $item.Class
if $Class = $Filter
? " " + substr($Name,4) + " " + $Class
$i = $i +1
endif
next
?
redim $aFilter[1]
$aFilter[0] = "organizationalUnit"
$aFilter[1] = "container"
$objOU.Filter = $aFilter
for each $item in $objOU
$Name = $item.Name
$pos = instrrev($LDAP,"/")
$DN = Left($LDAP,$pos) + $Name + ", " + substr($LDAP, $pos+1)
$j = EnumOUs($DN, $Filter);
$i = $i + $j
next
else
? "GetObject COM error: " + @error + " " + @serror
? "Bad path: " + $LDAP
endif
$EnumOUs = $i
Endfunction


[ 17. May 2003, 14:47: Message edited by: Howard Bullock ]
_________________________
Home page: http://www.kixhelp.com/hb/