Implement batch adding users and related account attribute information
implementation method is to perform the DSADD command loop by the for command.
Get the first symbol, quote%B to get the second symbol from%a ~%z.
The value of
, then the variable%A is 1, push down, the command line demonstrates as follows:
for /f “skip=1 eol=; tokens=1-9 delims=, ” %a in(c:\ADuserdata.csv) do
dsadd user cn=%a,cn=users,dc=sample,dc=net -upn %[email protected] %b –
pwd %c -fn %e -ln %d -dept %f -office %g -title %h -email %i-mustchpwd yes
Parameter meaning: SKIP = 1 skip the first line of data EOL =; Comment line starting character is “;” tokens = 1-9
1-9 variables Delims =, the segmentation symbol is “,”
in the address behind it is best to write the absolute address, so as not to find the computer. The CSV file is best edited in Excel,
1. The CSV file in the editor cannot be used by the command line, please turn off the Excel and run the command line program
2. -fn %E -Ln %D Name position is based on Chinese habits, which is intentional. If it is a foreigner’s name
can be filled in the CSV file in order.
3. Other DSADD parameters mean, please refer to DSADD User /? Tips or help documents from Windows2003.
Corresponding sample file aduserdata.csv content, it is recommended to use Excel edit:
User name, login name, password, surname, name, department, office, position, email
15 15, Baisan,[email protected], Bai, Three, Marketing Department, 301, Manager,[email protected]
伍 u, wuming,[email protected], Wu, Name, Marketing Department, 302, Staff,[email protected]
Koala, Kaola,[email protected], test, pull, marketing department, 302, staff,[email protected]
Batch Add test account
FOR /L %%a IN (1,1,4000) DO dsadd user cn=%%a,CN=Users,DC=cylan,DC=lfm,DC=com -upn %%[email protected] -samid %%a -pwd [email protected] -fn test -ln lfm -mustchpwd no -disabled yes