Search Windows and Linux Networking

Wednesday, October 6, 2010

How to create multiple users in Active Directory

To create multiple user account in Active Directory. There are many way to do this some of them are using :-
  1.  LDIFDE
  2.  Batch file (Using command net user add or  DsAdd User)
  3. VBScript

I will show how to create multiple user using excel .



Using Batch file.(Using Net command )

Preparing for batch file.
Open the excel and create file:-

In First row type the basic header to use in our batch file

Sr.No FirstName   LastName   UserName   Password    PasswordExpire 

Description  HomeDirectory    ProfileDirectory

E.g.
 
https://spreadsheets.google.com/ccc?key=0AlEFxdGpo-1EdHRKU2hncDZBTU13WGlzWlpZczc2NXc&authkey=CMO_5rAD&hl=en#gid=0


Now type the user's information in excel file
Type only FirstName, LastName and PasswordExpire field if you want to automatically set other field like UserName and password , HomeDirectory and ProfilePath.


E.g :- 
FirstName :- "Sandeep" 
LastName :- "Kapadane"


https://spreadsheets.google.com/ccc?key=0AlEFxdGpo-1EdFh0b0FZRG1JOG1iTVl0Z0cyVTNNNUE&hl=en&authkey=CJPV3cwE#gid=0


Now use the function to get use name

UserName =first Later of FirstName + LastName
Function in excel to get result is:-  
=CONCATENATE(LEFT(B2,1),C2)
 
so in my example UserName Will be skapane

https://spreadsheets.google.com/ccc?key=0AlEFxdGpo-1EdHFZdzJhNzdCQzRjSzlMMk14M3AwZ1E&hl=en&authkey=CMfZofEC#gid=0


Now drag the formula at the end of user list.

https://spreadsheets.google.com/ccc?key=0AlEFxdGpo-1EdF9mN0RPV01fNlY0ZVk5dDQ1UFR1VkE&hl=en&authkey=CMqD15QL#gid=0

Do Same for password , In my example 
Password=First three Later of UserName + @ +Sr.No of user.+ 2010

=CONCATENATE(LEFT(D2,3),"@",A2,2010)
and drag it at the end of user list.

https://spreadsheets.google.com/ccc?key=0AlEFxdGpo-1EdGlrYXZrVEU0NXc5ZDRVTUVFeUdpbXc&hl=en&authkey=CPGQ84AI#gid=0 

Set home directory and Profile directory same as UserName
For Home Directory =CONCATENATE("\\server\users\"D2)
For Profile Directory = CONCATENATE("\\server\Profiles\"D2)
and drag it at the end of user list.

in my example it is \\Server\Users\skapadane
https://spreadsheets.google.com/ccc?key=0AlEFxdGpo-1EdFhWdnQxTXB0NmhEYjFjMmNKOHM3LVE&hl=en&authkey=CLaHg4kI#gid=0

Now we will start to actually create batch file  using Net user Command

Net user Command does not create home directory and profile directory that's why we need to create three bat file for home directory mkhome.bat , for Profile directory mkprofile.bat and last one for user add useradd.bat

Now user Net sheet to create home Directory and use function
=CONCATENATE("mkdir ", Sheet1!H2) and drag it at the end of user. 


Do same for Profile Directory and use function 
=CONCATENATE("mkdir ",Sheet1!I2) and drag it at the end of user.

And now last for new user use the function 

=CONCATENATE("Net user"," ",Sheet1!D2," ",Sheet1!E2," ","/add"," ","/comment:",Sheet1!G2," ","/Expires:",Sheet1!F2," ","/homedir:",Sheet1!H2," ","/Profilepath:",Sheet1!I2," ","/Domain")
and drag it at the end of user.

https://spreadsheets.google.com/ccc?key=0AlEFxdGpo-1EdHo3bnVvVjhtRHhrbkJoZlpRaTEtZFE&hl=en&authkey=CNnTu5cF#gid=0

Now Select sheet mkhome and select the column copy it and past it in new Notepad and save the file as "Mkhomedir.bat"

Now Select Sheet mkprofile and select the column copy it and past it in new Notepad and save the file as "Mkprofile.bat"


Do Same for last sheet user add select the column copy it and past it in new Notepad and Save the file as "NewUser.bat"

Runing The batch file 
Run "MkHomeDir.bat" on double clicking on it . This will create home directory of user you are going to create.
Then Run "MkProfile.bat" on double clicking on it .This will create Profile directory of user you are going to crate. 
After that run "NewUser.bat" on double clicking on it . This will create new users in your domain in default Users container   
(Note: if you have given space in description you should use " description " to work )

Also see:-
Useing DSAdd User 
Using VBScript.


  

   

No comments:

Post a Comment