Jump to content

Recommended Posts

Posted

Does anyone know if you can create a bulk load of users in Active Directory by either using CSV (or similar) or if their is a power tools script that will do the job (and if so how to use it?)

 

Thanks,

Dave

Posted

Here is what i use for adding from an excel file. It may be of some use, not much needs changing... Four columns used in the excel sheet are: username,password,lastname,firstname

 

Dim 	objRootLDAP, objContainer, objUser, objShell
Dim 	objExcel, objSpread, intRow, strUser, strOU, strSheet
Dim 	strCN, strSam, strFirst, strLast, strPWD

		HomeServer							= 	"datastore2"
	strGroup							= 	"students"
	strOU 								= 	"OU=EHS," ' Note the comma
	strSheet 							= 	"Z:\!!-Scripts\2009\newusr\src.xls"

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

 	strDNSDomain 						= 	objRootLDAP.Get("DefaultNamingContext")
Set 	objExcel 							= 	CreateObject("Excel.Application")
Set 	objSpread 							= 	objExcel.Workbooks.Open(strSheet)
	intRow 								= 	1 'Row 1 often contains headings

Do Until objExcel.Cells(intRow,1).Value 	= 	""
  		strSam 								= 	Trim(objExcel.Cells(intRow, 1).Value)
  		strPWD 								= 	Trim(objExcel.Cells(intRow, 2).Value)
  		strLast 							= 	Trim(objExcel.Cells(intRow, 3).Value)
  		strFirst 							= 	Trim(objExcel.Cells(intRow, 4).Value)
  		strCN 								= 	strFirst & " " & strLast
Set 	objUser 							= 	objContainer.Create("User", "cn=" & strCN)
  		objUser.sAMAccountName 				= 	strSam
     	objUser.displayName 				= 	strCN
     	objUser.description					= 	strSam
  		objUser.givenName 					= 	strFirst
  		objUser.sn 							= 	strLast
      	objUser.HomeDrive 					= 	"Z:"
   	objUser.HomeDirectory 				= 	"\\"&HomeServer&"\"&strSam&"$"
  		objUser.SetInfo
  		objUser.userAccountControl 			= 	512
	'  objUser.pwdLastSet = 0
  		objUser.SetPassword strPWD
  		objUser.SetInfo
	intRow 								= 	intRow + 1


  
    Set objGroup 		= GetObject("LDAP://cn="&strGroup&",cn=users,"&strDNSDomain)
    objGroup.Add  objUser.AdsPath

  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...