Webmaster Forum

Go Back   Webmaster Forum > Scripting/Programming & Debugging > ASP & VBScript Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

ASP & VBScript Forum Need help from a webmaster with ASP or VBScript, you may ask in this forum?

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-25-2008, 03:22 PM
serge serge is offline
Junior Member
 
Join Date: Mar 2008
Posts: 1
serge is an unknown quantity at this point
Submit to Clesto Submit to Digg Submit to Reddit Submit to Furl Submit to Del.icio.us Submit to Jeqq Submit to Spurl
Default Retrieving info from ADSI and displying on text file

Hi guys. I have an AD group which has lots of "User" and "Contact" type objects. My goal is to retrieve certain fields of information from each "Contact" object and store them in a text file, one line per contact object.

So for example if there are two contact objects John and Sally, i want the information to be displayed as this:

Quote:
John, Marketing, Manager, 212-222-1234
Sally, Accounting, Director, 413-435-4321
And so on and so forth.

I have no coding experience, but i have still written a code based on tips ive found in books and on the web. The code is not tested yet. Would any of you guys be kind enough to go through it and give me some tips please? Thank you all so much.

Quote:
Option Explicit
On Error Resume Next

Dim qQuery, objConnection, objCommand, objRecordSet
Dim objFSO, objFolder, objShell, objTextFile, objFile, filePath

qQuery = "<LDAP://OU=ABCD,OU=OFFICES,DC=CA,DC=ABCD,DC=NET>;" & _ "(objectCategory=Contact);"

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Open "Provider=ADsDSOObject;"
objCommand.ActiveConnection = objConnection
objCommand.CommandText = qQuery
Set objRecordSet = objCommand.Execute



'Create File system object
Set objFSO = CreateObject("Scripting.FileSystemObject")

set objFile = nothing
set objFolder = nothing
set filePath = "C:\Folder\textfile.txt"

' OpenTextFile Method needs a Const value
' ForAppending = 8 ForReading = 1, ForWriting = 2

Const ForAppending = 8

Set objTextFile = objFSO.OpenTextFile _
(filePath, ForAppending, True)


'Output worker

While Not objRecordSet.EOF

' Writes to file
objTextFile.WriteLine(objRecordSet.Get("telephoneN umber") & ", "
& objRecordSet.Get("department") & ", "
& objRecordSet.Get("title") & ", "
& objRecordSet.Get("physicalDeliveryOfficeName") & ", "
& objRecordSet.Get("facsimileTelephoneNumber") & ", "
& objRecordSet.Get("mobile") & ", "
& objRecordSet.Get("proxyAddress") & ", "
& objRecordSet.Get("initials") )

objRecordSet.MoveNext

Wend

objConnection.Close
Reply With Quote

This ad is part of our Revenue Sharing program
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Retrieve Info From Form on HTML Page ecmoore12 ASP & VBScript Forum 1 02-06-2008 07:07 PM
Append text file frikkied ASP & VBScript Forum 3 10-31-2007 09:04 PM
Example of Inserting and Retrieving data from xml file hanusoft Web Developers & Development Software 0 10-01-2007 06:26 AM
text file to excel heavydee ASP & VBScript Forum 3 09-21-2007 05:55 PM
Directory domain name .com or .info Lovely General Web/Webmaster Forum 2 05-30-2007 08:56 AM


All times are GMT. The time now is 03:10 AM.


Creative Commons License
Powered by vBulletin Version 3.6.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.0.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30