Question
February 27, 2007 at 09:56 AM
bryan.jarnagin

Scripting a Search in AD for Users with Specific Location

by bryan.jarnagin . Updated 19 years, 7 months ago

I am trying to write a script that will search AD for the word “resident” in the Office field of the User Properties in Active Directory. Below is the code I’ve come up with, but for some reason it’s not working. Any vbscripters out there that can take a peek and tell me what I’m missing??

strBase = “>;” ‘ BaseDN should be the search base
strFilter = “;” ‘ Valid LDAP search filter
strAttrs = “;” ‘ Comma-seperated list
strScope = “” ‘ Should be on of Subtree, Onelevel or Base
‘ —— END CONFIGURATION ———

set objConn = CreateObject(“ADODB.Connection”)
objConn.Provider = “ADsDSOObject”
objConn.Open “Active Directory Provider”
set objRS = objConn.Execute(strBase & strFilter & strAttrs & strScope)
objRS.MoveFirst
While Not objRS.EOF
Wscript.Echo objRS.Fields(0).Value
objRS.MoveNext
Wend

This discussion is locked

All Comments