Query AD
After writing the script that generates the lab usage report, I looked at the BuildArray procedure and decided to change it to be more generic. This would allow me to use it in different ways.
The QueryAD procedure is a very simple script that loops through a recordset of objects returned from the Active Directory. The procedure uses the strQuery variable to represent your LDAP query.
This procedure accepts one parameter:
strQuery The strQuery parameter represents the Active Directory query you wish to perform and should look similar to the following:
strQuery = "SELECT " & strPropertyList & " FROM ‘" & strLDAPURL & "‘ WHERE objectClass = ‘" & strObjectClass & "‘"
I have shown the assignment using variables to represent the significant portions of the query, you could certainly manually build the query, but this format allows for much more flexibility.