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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to Reference a .Net dll in VBScript

Status
Not open for further replies.

sirnose1

Programmer
Nov 1, 2005
133
0
16
US
I have some code which searches the entire Domain forest for a user by email in Active Directory. I can do this in VB.net:

Dim allDomains = Forest.GetCurrentForest().Domains.Cast(Of Domain)()
Dim x As Integer = 0
For Each d As Domain In allDomains
Dim email As String = "brian@test.gov"
Dim searcher = New DirectorySearcher(New DirectoryEntry("LDAP://" + d.Name))
searcher.Filter = "(&(ObjectClass=user)(mail=" & email & "))"
Dim result As SearchResult = searcher.FindOne()
Dim myResult As ResultPropertyCollection

If result IsNot Nothing Then
myResult = result.Properties
x += 1
Console.WriteLine("Found it! " & email & "is on domain " & d.ToString())
End If
Next

Is it possible to reference the System.DirectoryServices and System.DirectoryServices.ActiveDirectory dll's in a vbscript page? If not is there a way to convert this code into VBScript?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top