iggzaplaya
MIS
I'm creating a vb script to enter an employee id number into a created attribute id field on each user account in active directory. I have a spreadsheet with the login names and id numbers that need added. I need to collect all names from active directory and compare the names to the login names on the spreadsheet, if the names match, I will populate the employee id number with the id number from the spreadsheet for that person. I have attached what I've gotten so far, but I'm not sure how to compare AD to the spreadsheet. Please help! Thanks ahead of time!!!
Here is my code so far:
Option Explicit
Dim adoCommand, adoConnection, strBase, strFilter, strAttributes
Dim objRootDSE, strDNSDomain, strQuery, adoRecordset, strDN , strOUPath
Dim objUser
Dim strProvider, strDataSource, strExtend, strFileName
Const ADS_PROPERTY_CLEAR = 1
' Connect to Excel Spreadsheet
strProvider = "Provider=Microsoft.Jet.OLEDB.4.0"
strExtend = "Extended Properties=Excel 8.0"
strFileName = funfix("jenzabar_ids.xls")
strDataSource = "Data Source=" & strFileName
strQuery = "Select * from [Sheet1$]
Do Until objRecordset.EOF
Wscript.Echo objRecordset.Fields.Item("Name"), _
objRecordset.Fields.Item("ID")
objRecordset.MoveNext
Loop
' Setup ADO objects.
Set adoCommand = CreateObject("ADODB.Command")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
adoCommand.ActiveConnection = adoConnection
' Search entire Active Directory domain.
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")
strBase = "<LDAP://" & stroupath & strDNSDomain & ">"
Here is my code so far:
Option Explicit
Dim adoCommand, adoConnection, strBase, strFilter, strAttributes
Dim objRootDSE, strDNSDomain, strQuery, adoRecordset, strDN , strOUPath
Dim objUser
Dim strProvider, strDataSource, strExtend, strFileName
Const ADS_PROPERTY_CLEAR = 1
' Connect to Excel Spreadsheet
strProvider = "Provider=Microsoft.Jet.OLEDB.4.0"
strExtend = "Extended Properties=Excel 8.0"
strFileName = funfix("jenzabar_ids.xls")
strDataSource = "Data Source=" & strFileName
strQuery = "Select * from [Sheet1$]
Do Until objRecordset.EOF
Wscript.Echo objRecordset.Fields.Item("Name"), _
objRecordset.Fields.Item("ID")
objRecordset.MoveNext
Loop
' Setup ADO objects.
Set adoCommand = CreateObject("ADODB.Command")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Open "Active Directory Provider"
adoCommand.ActiveConnection = adoConnection
' Search entire Active Directory domain.
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("defaultNamingContext")
strBase = "<LDAP://" & stroupath & strDNSDomain & ">"