Windows Server 2008 – Bulk User import

360 pts.
Active Directory
Bulk User Creation
User creation
Windows Server 2008
Windows Server User Profiles
Hello, I am hoping that someone will be able to assist me. I want to import about 300+ students into Active Directory. Anyone have any idea on how to do this in Windows 2008? Reply is urgent. Thank you.

Answer Wiki

Thanks. We'll let you know when a new response is added.

Please do not remove previous answer – simply add yours below. Previous answer:

See this similar question and answer.

Everything is simple when you have the tools. Here is a script to get you going. However, this script has some assumptions and you will need to make some modifications. It gives you a starting point. If you have more attributes just add them in and expand it. However the main logic is there and proven many times.
Also, if your import a list contains more attributes, send me a line and I will send you a list of attributes that could potentially exist in a properly created “mail enabled” user object in AD. You will then need to map the attributes to the data in the script and Violà!, your done.

I hope it works for you.
Here is the script:

' ---------------------------------------------------
' Script: createusers2.vbs
' Input: It uses a CSV file with layout logonname,firstname,lastname,password

Option Explicit

Dim sCSVFileLocation
Dim sCSVFile
Dim objFSO
Dim objFile
Dim strLine
Dim strItems
Dim oNewUser

' ----------LDAP connection variables----------
Dim oRootLDAP
Dim oContainer

' ----------Other variables--------------------
Dim sLogon
Dim sFirstName
Dim sLastName
Dim sDisplayName
Dim sPassword
Dim nPwdLastSet
Dim nUserAccountControl ' Used to enable the account
Dim sDomain

' ----------Modify this to match your company's AD domain----------

' ----------Input file location----------
sCSVFileLocation = "C:\myUserBase"
' ----------Full path to input file----------
sCSVFile = sCSVFileLocation&"myusers.csv"

' ----------Commands used to open the CSV file and select all of the records----------
set objFSO = CreateObject("Scripting.FileSystemObject")
set objFile = objFSO.OpenTextFile(sCSVFile, 1)

' ----------Create a connection to the Active Directory Users container.----------

Set oContainer = GetObject("LDAP://mycorpdc/OU=Import,dc=corp,dc=myDomain,dc=com")

' ----------Allows processing to continue even if an error occurs (i.e. dup user)----------
on error resume next

Do Until objFile.AtEndOfStream ' Reads the values (cells) in the sInputFile file.

' --------- Start creating user account----------
' Read variable information from the CSV file
' and build everything needed to create the account
strLine = objFile.ReadLine
strItems = split(strLine,",")

sLogon = strItems(0)
sFirstName = strItems(1)
sLastName = strItems(2)
sDisplayName = sFirstName&" "&sLastName
sPassword = strItems(3)

' ----------Build the User account----------
Set oNewUser = oContainer.Create("User","cn="&sFirstName&" "&SLastName)

oNewUser.put "sAMAccountName",lcase(sLogon)
oNewUser.put "givenName",sFirstName
oNewUser.put "sn",sLastName
oNewUser.put "UserPrincipalName",lcase(SLogon)&"@"&sDomain
oNewUser.put "DisplayName",sDisplayName
oNewUser.put "name",lcase(sLogon)

' ----------Write this information into Active Directory so we can----------
' modify the password and enable the user account

' ----------Change the users password----------
oNewUser.SetPassword sPassword
oNewUser.Put "pwdLastSet", -1

' ----------Enable the user account----------
oNewUser.Put "userAccountControl", 512


' ----------Used only for debugging----------
'if err.number = -2147019886 then
' msgbox "User logon " & sLogon & "already exists"
'End If

' --------- End of user account creation----------

Discuss This Question: 3  Replies

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • IronHedge
    Does not seem to work with Server 2008, I got line 45, A referral was returned from the server 8007202B, any others ??
    360 pointsBadges:
  • Labnuke99
    See this similar question and answer. It may be easier to use than a VBS script.
    32,960 pointsBadges:
  • IronHedge
    I ended up using "Mikey Magic Technologies Active User Manager" Its free and does a brilliant job Thank you for the reply but. trev
    360 pointsBadges:

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.


Share this item with your network: