| 
| 
| 
| #75055 - 2003-05-17 04:51 AM    Pre-UDF  EnumAD() |  
| Allen   KiX Supporter
 
       
 Registered:  2003-04-19
 Posts: 4562
 Loc:  USA
 | 
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:Here is a simple example:
 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
 
 
 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 ]
 |  
| Top |  |  |  |  
 
 Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart
 
 | 
| 
 
| 0 registered
and 793 anonymous users online. 
 | 
 |  |