Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADSI searching in VBS

Status
Not open for further replies.

Hokey

MIS
Oct 28, 2000
178
US
Is there a way to search/query the AD for a username (or list of usernames) that match search criteria (phone number, description, etc) in VBS/ADSI?

Thanks
 
Yep, sure can try username...other fields...?

' Create WSH objects and populate with data from the Domain/AD
set wshNetwork = WScript.CreateObject("WScript.Network")
set wshShell = WScript.CreateObject("WScript.Shell")

' Wait for up to 30 seconds for the user-specific data to be located and loaded from Domain/AD
HurryUp = Timer + 30
Do
Wscript.Sleep 100 ' Check every 100mS
Loop until wshNetwork.username <> &quot;&quot; or HurryUp < Timer
If wshNetwork.username=&quot;&quot; then ProblemGettingDomainData

' Set some variables
User = wshNetwork.username
Domain = wshNetwork.userdomain
Computer = wshNetwork.computername

' Determine the users Domain/AD Group membership
adspath=&quot;WinNT://&quot; & domain & &quot;/&quot; & user

' Create an object and populate it with user account properties from the Domain/AD
set adsobj = getobject(adspath)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top