Dim rootDSE, domainObject
This code, though complex looking, simply connect to RootDSE which is as the name implies the top of the directory, gets “defaultNaming Context” which is the domain that the script is run on, and binds to it using LDAP to return the “domainObject”
Next, we create a text file, named “c:\user.csv”.
Set fs = CreateObject (“Scripting.FileSystemObject”)
Then, we call a subroutine, ExportUsers, that writes user information to a file.
After running it, we clean up, send a message box saying we’re done.
Set oDomain = Nothing
So, here is the subroutine that does most of the work.
We have a for loop that looks at the domain folder and looks at all the object there. Naturally at the domain level, everything is just containers and OUs. If it encounters an OU or a container, it simply runs itself again, this time on the OU/Container if it is not empty.
Function UsersinOU (oObject)
This is about it. One of my next articles will show how to this more efficiently, using LDAP queries