djhawthorn
Technical User
I have the following code which enumerates the list of OU's in the domain and outputs the list to a HTA (indented using UL and LI tags):
Though as we have some 60,000 objects in the domain, it takes a while to build the list
Is there a faster way to enumerate (or filter on) only OU objects? I started playing around with ADO, however as soon as it loops it crashes, probably because I'm trying to instanciate two of the same object.
![[ponder] [ponder] [ponder]](/data/assets/smilies/ponder.gif)
The dumber they think you are, the more surprised they'll be when you kill them! ![[machinegun] [machinegun] [machinegun]](/data/assets/smilies/machinegun.gif)
![[rofl2] [rofl2] [rofl2]](/data/assets/smilies/rofl2.gif)
Code:
Function DoRecursiveLookup(strObjectDN)
Set objConnection = GetObject("LDAP://" & strObjectDN)
For each objChild In objConnection
If (objChild.Class = "organizationalUnit") Then
strOUName = Right(objChild.Name, Len(objChild.Name) - 3)
strOUPath = objChild.DistinguishedName
'Do some stuff to print the OU name to the HTA
'Call the function again to enumerate sub-OU's
DoRecursiveLookup("ou=" & strOUName & "," & strObjectDN)
End If
Next
End Function
Though as we have some 60,000 objects in the domain, it takes a while to build the list
Is there a faster way to enumerate (or filter on) only OU objects? I started playing around with ADO, however as soon as it loops it crashes, probably because I'm trying to instanciate two of the same object.
![[ponder] [ponder] [ponder]](/data/assets/smilies/ponder.gif)
![[laughtears] [laughtears] [laughtears]](/data/assets/smilies/laughtears.gif)
![[machinegun] [machinegun] [machinegun]](/data/assets/smilies/machinegun.gif)
![[rofl2] [rofl2] [rofl2]](/data/assets/smilies/rofl2.gif)