Error When running Script to Create Bulk AD Accounts

Hello Experts.

I have about 6500 user accounts I need to create in active directory and I was wondering if there was a quick way of doing this.   I got this script online, but I get an error message


Script: f:\prg\scriptsbatch\adtools\CreateBulk.vbs
Line: 19
Char: 1
Error: 0x80005000
Code:  80005000
Source: (null)

Here is my user file

CreateBulkUserList.xls
====================
sAMAccountName      CN      GivenName      SN      Password
autotest1      Auto1      Auto1 Test1      Test1      P@ssword
autotest2      Auto2      Auto2 Test2      Test2      P@ssword
autotest3      Auto3      Auto3 Test3      Test3      P@ssword
autotest4      Auto4      Auto4 Test4      Test4      P@ssword
autotest5      Auto5      Auto5 Test5      Test5      P@ssword
autotest6      Auto6      Auto6 Test6      Test6      P@ssword


' UserSpreadsheet .vbs
' Sample VBScript to create User accounts from a spreadsheet
' Author Guy Thomas http://computerperformance.co.uk/
' Version 4.6 - June 2005
' ------------------------------------------------------' 
Option Explicit
Dim objRootLDAP, objContainer, objUser, objShell
Dim objExcel, objSpread, intRow
Dim strUser, strOU, strSheet
Dim strCN, strSam, strFirst, strLast, strPWD

' -------------------------------------------------------------'
' Important change OU= and strSheet to reflect your domain
' -------------------------------------------------------------'
strOU = "OU=GRPsers, dc=mytest, dc=local" ' Note the comma
strSheet = "F:\prg\ScriptsBatch\AD_Management\CreateBulkUserList.xls"
' Bind to Active Directory, Users container.
Set objRootLDAP = GetObject("LDAP://rootDSE")
Set objContainer = GetObject("LDAP://" & strOU & _
objRootLDAP.Get("defaultNamingContext")) 
' Open the Excel spreadsheet
Set objExcel = CreateObject("Excel.Application")
Set objSpread = objExcel.Workbooks.Open(strSheet)
intRow = 2 'Row 1 often contains headings
' Here is the 'DO...Loop' that cycles through the cells
' Note intRow, x must correspond to the column in strSheet
Do Until objExcel.Cells(intRow,1).Value = ""
   strSam = Trim(objExcel.Cells(intRow, 1).Value)
   strCN = Trim(objExcel.Cells(intRow, 2).Value) 
   strFirst = Trim(objExcel.Cells(intRow, 3).Value)
   strLast = Trim(objExcel.Cells(intRow, 4).Value)
   strPWD = Trim(objExcel.Cells(intRow, 5).Value)
   ' Build the actual User from data in strSheet.
   Set objUser = objContainer.Create("User", "cn=" & strCN)
   objUser.sAMAccountName = strSam
   objUser.givenName = strFirst
   objUser.sn = strLast
   objUser.SetInfo
   ' Separate section to enable account with its password
   objUser.userAccountControl = 512
   objUser.pwdLastSet = 0
   objUser.SetPassword strPWD
   objUser.SetInfo
intRow = intRow + 1
Loop
objExcel.Quit 
WScript.Quit 
' End of Sample UserSpreadsheet VBScript.

Open in new window

epicazoAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

snoopscratchyCommented:
Hello,

Maybe the problem comes from this line :

strOU = "OU=GRPsers, dc=mytest, dc=local" ' Note the comma

Open in new window


You need to set it to your current domain and probably that dc=mytest, dc=local does not match your current domain.

Can you try this and tell us if it helps ?

Yoann
epicazoAuthor Commented:
I put that here only for MASKING purposes, but still didn't work.
snoopscratchyCommented:
Right,

The error 0x80005000 means "The specified directory service attribute or value does not exist" and I think that I have identified your problem :

The fact is that you use the full LDAP path in "strOU", so to match the path you set "strOU" to, you have to do the following :

Change
Set objContainer = GetObject("LDAP://" & strOU & _
objRootLDAP.Get("defaultNamingContext"))

Open in new window

To
Set objContainer = GetObject("LDAP://" & strOU)

Open in new window



objRootLDAP.Get("defaultNamingContext") returns "dc=mytest, dc=local" so your LDAP path was looking like "OU=MyOU,dc=mytest,dc=local,dc=mytest,dc=local"

Hope this works now !

Yoann

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
epicazoAuthor Commented:
Thanks a million
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Legacy OS

From novice to tech pro — start learning today.