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?
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?