
November 6th, 2006, 07:56 AM
|
|
Contributing User
|
|
Join Date: May 2006
Posts: 33
  
Time spent in forums: 7 h 50 m 43 sec
Reputation Power: 4
|
|
|
ADSI help
I am trying to search active directory to return a list of email address. I have a text file with a list of names. When I run my script I get an error and one able to help me?
Code:
Const ForReading = 1
Const ForAppending = 8
Const ADS_SCOPE_ONELEVEL = 1
set objFSO = CreateObject("Scripting.FileSystemObject")
set objFile = objFSO.OpenTextFile("list.txt", ForReading)
set objNFile = objFSO.OpenTextFile("results.txt", ForAppending)
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
objCommand.Properties("searchscope") = ADS_SCOPE_ONELEVEL
Wscript.Echo "Reading File"
Do While objFile.AtEndOfStream = False
strLine = objFile.ReadLine
objCommand.CommandText = "Select email FROM 'LDAP://domain name' WHERE description = 'strLine'"
Set objRecordSet = objCommand.Execute
objNFile.WriteLine(strLine & " " & objRecordSet.Fields("email"))
Loop
objFile.Close
objNFile.Close
when I run it i get the error
Line: 22
Char: 9
Error: Unspecified error
Code: 80004005
Source: Provider
|