Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


help to save data

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,41397
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> help to save data
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 help to save data - 12/22/2006 6:26:41 AM   
  adviper1

 

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") & "]"
 
   Wscript.Echo "Group Member(s):"
   arrMembers = objRecordSet.Fields("member")

   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
 
 
Post #: 1
 
 RE: help to save data - 12/22/2006 6:31:17 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: offline
Search this forum for these terms and you should find code to point you in the right direction:

FileSystemObject
OpenTextFile
CreateTextFile
WriteLine

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to adviper1)
 
 
Post #: 2
 
 RE: help to save data - 12/27/2006 7:43:57 AM   
  adviper1

 

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

(in reply to ebgreen)
 
 
Post #: 3
 
 RE: help to save data - 1/2/2007 2:02:35 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: offline
Try changing this:

objFso.Write objRecordSet.Fields("Name").Value

to this:

objFile.WriteLine objRecordSet.Fields("Name").Value

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to adviper1)
 
 
Post #: 4
 
 RE: help to save data - 1/2/2007 2:18:30 AM   
  adviper1

 

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:

objFso.Write objRecordSet.Fields("Name" & "sAMAccountName").Value



again thanks....

(in reply to ebgreen)
 
 
Post #: 5
 
 RE: help to save data - 1/2/2007 2:51:28 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: offline
objFile.WriteLine objRecordSet.Fields("Name").Value & " - " & objRecordSet.Fields("sAMAccountName").Value

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to adviper1)
 
 
Post #: 6
 
 RE: help to save data - 1/2/2007 4:10:39 AM   
  adviper1

 

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


thanks...

(in reply to ebgreen)
 
 
Post #: 7
 
 RE: help to save data - 1/2/2007 4:35:50 AM   
  ebgreen


Posts: 5246
Score: 31
Joined: 7/12/2005
Status: offline
objCommand.CommandText = "SELECT Name,  sAMAccountName FROM  _
'LDAP://ou=studenths,dc=btbnss,dc=stier,dc=org' WHERE objectCategory='user'"

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to adviper1)
 
 
Post #: 8
 
 RE: help to save data - 1/2/2007 4:46:26 AM   
  adviper1

 

Posts: 5
Score: 0
Joined: 12/11/2006
From: new york
Status: offline
Hi EBGreen, thanks a bunch, I need new glasses, I missesd that....
Talk to you soon...

(in reply to ebgreen)
 
 
Post #: 9
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> help to save data Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts