Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Batch creation of domain users using batch processing

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Task requirements:

The domain name is WorldSkills2017.china, and there is an OU named test. A domain group named IT has been created in this OU, which requires the batch creation of 20 domain users with the user name it001-it020 and the password Skills39, and all join the IT group.

Let's break down the task, starting with how to use the dsadd user command to create a domain user.

For example, to first create a user named zhangsan in the test OU in the WorldSkills2017.china domain, here are the specific commands:

"cn=zhangsan, ou=test, dc=WorldSkills2017, dc=china", which is an expression of LDAP. Cn represents the user name, ou represents OU, and the domain name is divided into two parts each represented by two dc.

The-upn option is used to specify the user's login name.

The-memberof option is used to specify the group to which the user belongs, and the group information is also expressed in the way of LDAP.

The-pwd option is used to specify the user's password.

The user zhangsan was created successfully after the command was executed:

And has automatically joined the IT group:

Once you have mastered the command, let's continue to write the batch script, which uses the for loop, and the written script is shown in the following figure:

For is a very powerful command in batch processing, / l is one of its parameters, and for / l indicates that the loop performs an operation.

% an is a defined variable, and% an is a fixed format for variables in a batch.

In specifies the interval of the loop. The first 1 represents the initial value of the loop, the second 1 represents the loop step, and the last 9 represents the loop termination value in the format of in (start,step,end). % an in means% an as a loop variable, whose value varies with the execution of the loop, starting at 1 and adding 1 to 9 for each loop.

The do is followed by what you want to do with each loop, the previous dsadd user command.

Because the title requires it001. It020 is named, so two commands are used to execute it.

After writing the script in notepad, change the extension to .bat, run the script, and successfully add 20 users in batch.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report