Académique Documents
Professionnel Documents
Culture Documents
com/questions/209549/how-can-i-quickly-create-100-users-on-my
-active-directory-for-testing-purposes
http://www.testools.net/2013/01/how-to-create-several-users-in-active.html
https://www.petri.com/create_users_for_testing_purposes#1
If you want to create a large amount of test user accounts in your domain or loc
al accounts on your workstation, you can do so in more than one way. On this pag
e I ll try to list a few of these methods.
By
By
By
By
using
using
using
using
the
the
the
the
If you happen to have some nice scripts that can do the same job in other method
s (oh yes, there are other methods), please do send me an e-mail and I ll upload i
t to this page .
Windows Server 2003 AD Note: Windows Server 2003 Active Directory is configured,
by default, to request that any user that you create will have a password that
is complex and with a minimum of 7 characters. Some methods described here (main
ly method #3 and #4) cannot add the password attribute to a user account. In ord
er for these methods to work in your test environment you must first disable the
password requirement for the Windows Server 2003-based Domain. Read my Disable
Password Requirements in Windows Server 2003 Domains article for more info.
Method #1: By using the NET USER command
NET USER is an old NT-related user manipulation command. I will not list all of
it s attributes here (you can find for yourself by going to the Help and Support s
ite on your computer). I do not usually use the NET USER command in an AD enviro
nment, mostly due to the fact that it is not tailored for AD objects at all, but
still, it can be used for our needs.
You can use the FOR and NET USER commands to accomplish the task in a quick and d
irty way, without scripting or writing any code. For example, if you type from th
e command prompt:
1. FOR /L %i in (1,1,500) DO NET USER MyUser%i /ADD
This will result in creating 500 new users, named MyUser1, MyUser2, etc. You can
, of course, customize the FOR command s parameters. See the FOR command help for
more options.
You can also set the user s password (in this case
Note: If you re using a W2K PRO or XP PRO computer that is connected to an Active
Directory network and you wish to create local users on that computer
run the co
mmand above. However, if you want, from that computer, to create users in the Ac
tive Directory database on the DC, use this command instead:
1 FOR /L %i in (1,1,500) DO NET USER MyUser%i P@ssw0rd /domain /ADD
To create users with pre-configured names (for example a file with all your comp
any s usernames or a database with usernames) create a text file like this one:
1
2
3
4
5
6
7
8
daniel
moshe
yossy
gabi
ran
bijo
baruch
bibi
Like with NET USER, the DSADD USER command can be used along with a text or CSV
file that contains a list of all the users that you want to build.
Create a text file like this one:
1 Blue,Kelly,bluek,04-6545645
2 Ben-Sachar,Ido,bensachari,03-7634545
3 Fluegel,Jay,fluegelj,03-9875765
4 Grande,Jon,grandej,02-6674534
5 Hankin,Alex,hankina,04-8856476
6 Jiang,George,jiangg,08-7636344
7 Kelly,Robert,kellyr,03-5568336
8 Kelly,Bob,kellyb,03-9567474
9 Li,Yuhong,liy,02-5462272
10 Moreland,Barbara,morelandb,04-88293922
11 Naik,Mandar,naikm,03-5531190
12 O'Donnell,Claire,odonnellc,03-5111930
13 Smith,John,smithj,03-8102201
Name the file USERS.TXT and place it in a directory.
Now open a CMD in that directory and run the following command:
1 for /F "eol=; tokens=1,2,* delims=," %%i in (users.txt) do dsadd user "cn=%%j
%%i,ou=Test OU,dc=dpetri,dc=net" -samid %%k -upn %%k@dpetri.net -fn %%j -ln %%i
-display "%%j %%i" -pwd P@ssw0rd -disabled yes
This will create user accounts with the names found in the USERS.TXT file.
Imagine the power of such a script!
Method #3: By using the CSVDE command
CSVDE is a command that can be used to import and export objects to and from the
AD into a CSV-formatted file. A CSV (Comma Separated Value) file is a file easi
ly readable in Excel.
I will not go to length into this powerful command, but I will show you some bas
ic samples of how to import a large number of users into your AD. Of course, as
with the DSADD command, CSVDE can do more than just import users. Consult your h
elp file for more info.
For example, lets say I would like to create a number of very simple users. Just
the necessary information, nothing more.
Create a text file like this one:
1 dn,sAMAccountName,userPrincipalName,userAccountControl,objectClass
2 "CN=Amie Baldwin,OU=Test OU,DC=dpetri,DC=net",amieb,amieb@dpetri.net,512,user
3 "CN=Scott Culp,OU=Test OU,DC=dpetri,DC=net",scottc,scottc@dpetri.net,512,user
4 "CN=Derek Graham,OU=Test OU,DC=dpetri,DC=net",derekg,derekg@dpetri.net,512,use
r
5 "CN=Stephanie Bourne,OU=Test OU,DC=dpetri,DC=net",stephanieb,stephanieb@dpetri
.net,512,user
6 "CN=Matthew Dunn,OU=Test OU,DC=dpetri,DC=net",matthewd,matthewd@dpetri.net,512
,user
1 DN,objectClass,name,homeMDB,cn,displayName,mail,givenName,proxyAddresses,sAMAc
countName,sn,userAccountControl,userPrincipalName,homeMTA,msExchHomeServerName,m
ailNickname,countryCode,c,l,homePhone,mobile,telephoneNumber,co,wWWHomePage
2 "CN=kuku levi,OU=Test OU,DC=dpetri,DC=net",user,kuku levi,"CN=Mailbox Store (S
ERVER100),CN=First Storage Group,CN=InformationStore,CN=SERVER100,CN=Servers,CN=
First Administrative Group,CN=Administrative Groups,CN=Dpetri,CN=Microsoft Excha
nge,CN=Services,CN=Configuration,DC=dpetri,DC=net",kuku levi,kuku levi,kukul@dpe
tri.net,kuku,SMTP:kukul@dpetri.net;X400:c=us';a= ';p=Dpetri';o=Exchange';s=levi'
;g=kuku';,kukul,levi,512,kukul@dpetri.net,"CN=Microsoft MTA,CN=SERVER100,CN=Serv
ers,CN=First Administrative Group,CN=Administrative Groups,CN=Dpetri,CN=Microsof
t Exchange,CN=Services,CN=Configuration,DC=dpetri,DC=net",/o=Dpetri/ou=First Adm
inistrative Group/cn=Configuration/cn=Servers/cn=SERVER100,kukul,376,IL,Tel-Aviv
,03-4534545,051-345345,03-4534545,ISRAEL,www.petri.com
3 "CN=momo levi,OU=Test OU,DC=dpetri,DC=net",user,momo levi,"CN=Mailbox Store (S
ERVER100),CN=First Storage Group,CN=InformationStore,CN=SERVER100,CN=Servers,CN=
First Administrative Group,CN=Administrative Groups,CN=Dpetri,CN=Microsoft Excha
nge,CN=Services,CN=Configuration,DC=dpetri,DC=net",momo levi,momo levi,momol@dpe
tri.net,momo,SMTP:momol@dpetri.net;X400:c=us';a= ';p=Dpetri';o=Exchange';s=levi'
;g=momo';,momol,levi,512,momol@dpetri.net,"CN=Microsoft MTA,CN=SERVER100,CN=Serv
ers,CN=First Administrative Group,CN=Administrative Groups,CN=Dpetri,CN=Microsof
t Exchange,CN=Services,CN=Configuration,DC=dpetri,DC=net",/o=Dpetri/ou=First Adm
inistrative Group/cn=Configuration/cn=Servers/cn=SERVER100,momol,376,IL,Tel-Aviv
,03-9879878,053-878345,03-9879878,ISRAEL,www.msn.co.il
4 "CN=jojo levi,OU=Test OU,DC=dpetri,DC=net",user,jojo levi,"CN=Mailbox Store (S
ERVER100),CN=First Storage Group,CN=InformationStore,CN=SERVER100,CN=Servers,CN=
First Administrative Group,CN=Administrative Groups,CN=Dpetri,CN=Microsoft Excha
nge,CN=Services,CN=Configuration,DC=dpetri,DC=net",jojo levi,jojo levi,jojol@dpe
tri.net,jojo,SMTP:jojol@dpetri.net;X400:c=us';a= ';p=Dpetri';o=Exchange';s=levi'
;g=jojo';,jojol,levi,512,jojol@dpetri.net,"CN=Microsoft MTA,CN=SERVER100,CN=Serv
ers,CN=First Administrative Group,CN=Administrative Groups,CN=Dpetri,CN=Microsof
t Exchange,CN=Services,CN=Configuration,DC=dpetri,DC=net",/o=Dpetri/ou=First Adm
inistrative Group/cn=Configuration/cn=Servers/cn=SERVER100,jojol,376,IL,Tel-Aviv
,03-2424478,053-654654,03-2424878,ISRAEL,www.cnn.com
For example, just like with the CSVDE command, lets say I would like to create a
number of very simple users. Just the necessary information, nothing more.
Create a text file like this one:
dn: CN=Amie Baldwin,OU=Test OU,DC=dpetri,DC=net
changetype: add
cn: Amie Baldwin
objectClass: user
name: Amie Baldwin
sAMAccountName: amieb
telephoneNumber: 555-1234
userAccountControl: 514
userPrincipalName: amieb@dpetri.net
dn: CN=Scott Culp,OU=Test OU,DC=dpetri,DC=net
changetype: add
cn: Scott Culp
department: Accounting
objectClass: user
name: Scott Culp
sAMAccountName: scottc
telephoneNumber: 555-1236
userAccountControl: 512
userPrincipalName: scottc@dpetri.net
dn: CN=Derek Graham,OU=Test OU,DC=dpetri,DC=net
changetype: add
cn: Derek Graham
department: Accounting
objectClass: user
name: Derek Graham
sAMAccountName: derekg
telephoneNumber: 555-1239
userAccountControl: 512
userPrincipalName: derekg@dpetri.net
dn: CN=Stephanie Bourne,OU=Test OU,DC=dpetri,DC=net
changetype: add
cn: Stephanie Bourne
department: Accounting
objectClass: user
name: Stephanie Bourne
sAMAccountName: stephanieb
telephoneNumber: 555-1239
userAccountControl: 512
userPrincipalName: stephanieb@dpetri.net
dn: CN=Matthew Dunn,OU=Test OU,DC=dpetri,DC=net
changetype: add
cn: Matthew Dunn
department: Accounting
objectClass: user
name: Matthew Dunn
sAMAccountName: matthewd
telephoneNumber: 555-1230
userAccountControl: 512
userPrincipalName: matthewd@dpetri.net
Note that unlike the CSV-formatted file, the LDIF file is quite easy to understa
nd and edit in Notepad. However, you may find it easier to edit a large number o
f users via Excel than through Notepad, that s why the CSV-formatted file will sti
ll be easier to manipulate than the LDIF-formatted file.
Name the file USERS.LDF and place it in a directory.
Open a CMD in that directory and run the following command:
ldifde -i -f users.ldf
1
ldifde -i -f users.ldf
(use your own path)
This will create 5 user accounts with the names found in the USERS.LDF file.
Since the only difference between the CSVDE and LDIFDE commands is the file form
at I will stop here. Remember that you can add almost any user-configurable attr
ibute by using these commands. Test them on your own, and if you come up with a
truly amazing result please share it with us .
Links
Step-by-Step Guide to Bulk Import and Export to Active Directory
http://www.microsoft.com/windows2000/techinfo/planning/activedirectory/bulksteps
.asp
Importing and exporting directory information
http://www.microsoft.com/windows2000/en/server/help/sag_ad_ldif_csv.htm
Using LDIFDE to Import and Export Directory Objects to Active Directory
237677
http://support.microsoft.com/?kbid=237677
How to Use Csvde.exe to Import Contacts into Active Directory 300409
http://support.microsoft.com/?kbid=300409