Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Modifying AD from a text file

Status
Not open for further replies.

arohl74

MIS
May 9, 2003
10
US
I have a situation similar to thread329-1218115. We have a text file from Peoplesoft that has the Employee Name, Department, Office, Region and Phone Number. I want to import this data into AD form the tab delimited text file.

In thread329-1218115 I don't see how the example is for mass updates. How do you modify it to do a mass update using the information from the text file?

I am new to VBScript and would appreciate any help.
 
It appears your text file has all the information seperated by a comma. You should simply import that info into an excel spreadsheet, label the columns accordingly, and then use the script mentioned above to make your changes.
 
It's actually a tab-delimited file. Here is some code that I found on the internet and modified...

On Error Resume Next

Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adCmdText = &H0001
Const ADS_PROPERTY_APPEND = 3

'Col1=sEmployeeID Text
'Col2=sEmployeeName Text
'Col3=sEmployeeClass Text
'Col4=sEmployeeStatus Text
'Col5=sOfficeID Text
'Col6=sReporting Office Text
'Col7=sRegion Text
'Col8=sBusinessTitle Text
'Col9=sHireDate Text

Set Objou = GetObject("LDAP://OU=PSTEST,DC=russellreynolds,DC=com")

Dim sGivenName
Dim sOffice
Dim sSurname
Dim STitle

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")

strPathtoTextFile = "C:\script\"

objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & strPathtoTextFile & ";" & _
"Extended Properties=""text;HDR=NO;FMT=TabDelimited"""

objRecordset.Open "SELECT * FROM test_emp_info.txt", _
objConnection, adOpenStatic, adLockOptimistic, adCmdText

Do Until objRecordset.EOF
Wscript.Echo "EmployeeName: " & objRecordset.Fields.Item("sEmployeeName")
Wscript.Echo "Office: " & objRecordset.Fields.Item("sOffice")
Wscript.Echo "Bussiness Title: " & objRecordset.Fields.Item("sTitle")
objRecordset.MoveNext
'Loop

'set account properties
objUser.Put "physicalDeliveryOfficeName", soffice
objUser.Put "title", sTitle

'save the account
objUser.SetInfo

Exit Do


Loop

What do you think?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top