?
Solved

Error When running Script to Create Bulk AD Accounts

Posted on 2012-03-22
4
Medium Priority
?
376 Views
Last Modified: 2012-03-26
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

0
Comment
Question by:epicazo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 1

Expert Comment

by:snoopscratchy
ID: 37752805
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
0
 

Author Comment

by:epicazo
ID: 37753398
I put that here only for MASKING purposes, but still didn't work.
0
 
LVL 1

Accepted Solution

by:
snoopscratchy earned 2000 total points
ID: 37753573
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
0
 

Author Closing Comment

by:epicazo
ID: 37767458
Thanks a million
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In a hurry?.. scroll down to "HERE's HOW TO DO IT" Section. Greetings All, I was going to post this as question/solution, but its seems more appropriate as an article considering its length.  I felt it important to illucidate all the details c…
INTRODUCTION The purpose of this document is to demonstrate the Installation and configuration of the Data Protection Manager product. Note that this demonstration was prepared on the basis of Windows OS is 2008 R2 and DPM 2010. DATA PROTECTI…
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question