Posts: 5
Score: 0
Joined: 12/11/2006
From: new york
Status: offline
Original message moved by ebgreen Reason : Moved to appropriate forum Hi, i am working on a script that searches domain for users... that part i have working.. now i would like to put the data into a file to check and save. i am script on and off for a few year but have done very little with it.... Now I can get it to print to the screen but would like to get it in to a text file.. any help would be appreciated... thanks..... here is my checking users:
Set objConnection = CreateObject("ADODB.Connection") objConnection.Open "Provider=ADsDSOObject;" Set objCommand = CreateObject("ADODB.Command") objCommand.ActiveConnection = objConnection objCommand.CommandText = _ "<GC://dc=xx,dc=xxxxxxxx,dc=com>;(objectCategory=Group);" & _ "distinguishedName,name,member;subtree"
Set objRecordSet = objCommand.Execute While Not objRecordSet.EOF Wscript.Echo objRecordSet.Fields("Name") Wscript.Echo "[" & _ objRecordSet.Fields("distinguishedName") & "]"
If IsArray(objRecordSet.Fields("member")) Then For Each strMember in arrMembers Wscript.Echo vbTab & strMember Next Else Wscript.Echo vbTab & "None" End If Wscript.Echo VbCrLf objRecordSet.MoveNext Wend objConnection.Close
Posts: 5
Score: 0
Joined: 12/11/2006
From: new york
Status: offline
Hi.. Still having trouble putting searched data into file.... i am still able to get the data to display on the screen but I either get no data in the file or errors... this is the part that i can get t work to display on the screen
Set objRootDSE = GetObject("LDAP://RootDSE") strDomain = objRootDSE.Get("DefaultNamingContext") Const ADS_SCOPE_SUBTREE = 2 dim Fso, objFso, objFile Set objConnection = CreateObject("ADODB.Connection") Set objCommand = CreateObject("ADODB.Command") objConnection.Provider = "ADsDSOObject" objConnection.Open "Active Directory Provider" Set objCommand.ActiveConnection = objConnection objCommand.Properties("Page Size") = 1000 objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE objCommand.CommandText = "SELECT Name FROM _ 'LDAP://ou=studenths,dc=btbnss,dc=stier,dc=org' WHERE objectCategory='user'" Set objRecordSet = objCommand.Execute objRecordSet.MoveFirst Do Until objRecordSet.EOF Wscript.Echo objRecordSet.Fields("Name").Value objRecordSet.MoveNext Loop _______ but then when I tried to add the data (part of it). after a multitude of changes i was not getting anywhere.... i believe it is naming the variable that is my problem... just not sure how to fix... thanks....
Const ForAppending = 8 Set objFso = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.OpenTextFile("C:\scriptlog\people1.txt", 8) objRecordSet.MoveFirst Do Until objRecordSet.EOF objFso.Write objRecordSet.Fields("Name").Value objRecordSet.MoveNext
Posts: 5
Score: 0
Joined: 12/11/2006
From: new york
Status: offline
HI ebgreen... thanks... had time and fix the problem, thanks... this next one i could not find anywhere how to write both "Name" and sAMAccountName" :
objCommand.CommandText = "SELECT Name sAMAccountName FROM _ 'LDAP://ou=studenths,dc=btbnss,dc=stier,dc=org' WHERE objectCategory='user'" Set objRecordSet = objCommand.Execute
also guessing that it could do this but agian not getting this far:
Posts: 5
Score: 0
Joined: 12/11/2006
From: new york
Status: offline
Hi ebgreen,,, again thanks for the write portion of this... but still having a problem with the set... when it was just one of the (Name or sAMAccountName) it worked when using both receive error that "80040e14" one or more errors occurred during processing of the command. (says error is on the line that has the "set")
objCommand.CommandText = "SELECT Name sAMAccountName FROM _ 'LDAP://ou=studenths,dc=btbnss,dc=stier,dc=org' WHERE objectCategory='user'" Set objRecordSet = objCommand.Execute