• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 282
  • Last Modified:

how to write script for creating users automatically(altogether) in windows 2000 server domain?

Hi...
We rebuilt our PDC...Now we want to create all users through script...

how to write script for creating user in windows 2000 server domain?
What is the syntax?

For eg: User name is "Joji Joseph" and logon ID should be "joji" in group IT

Awaiting ur quick reply...

Thanks...
Joji
0
JojiJoseph_1975
Asked:
JojiJoseph_1975
  • 3
2 Solutions
 
Tecki_TrojansCommented:
Hello Bro
Let me know if this works for u .....................


' Taken from ADS_USER_FLAG_ENUM
Const ADS_UF_NORMAL_ACCOUNT = 512

set objParent = GetObject("LDAP://<ParentDN>")
set objUser   = objParent.Create("user", "cn=<UserName>") ' e.g. joes
objUser.Put "sAMAccountName", "<UserName>"   ' e.g. joes
objUser.Put "userPrincipalName", "<UserUPN>" ' e.g. joes@rallencorp.com
objUser.Put "givenName", "<UserFirstName>"   ' e.g. Joe
objUser.Put "sn", "<UserLastName>"           ' e.g. Smith
objUser.Put "displayName", "<UserFirstName> <UserLastName>" ' e.g. Joe Smith

' CORRECTION: If you don't set userAccountControl, then by default
'             the value of 514 (normal account + disabled) will be set for it.
'             In this instance by setting it to 512, the account will not
'             be disabled, and if you have password complexity enabled in
'             your forest, the script will fail because a password was not
'             set prior to the account being enabled.  The solution is to
'             not set userAccountControl here.
' objUser.Put "userAccountControl", ADS_UF_NORMAL_ACCOUNT

objUser.SetInfo
objUser.SetPassword("<Password>")
objUser.AccountDisabled = FALSE
objUser.SetInfo


Enjoy ..........
0
 
GuruGaryCommented:
Are you trying to automate adding a bunch of users at one time?  This will do one at a time ...

For a batch file, you could use the "net user" and "net group" commands to accomplish your task.  For example, if you want to use it to set up the 3 fields you entered above (with an initial default password of "password"), you could save the following as "userscript.bat":

@echo off
net user %2 password /add /fullname:%1
net group IT %2 /add

Then just run it like:
userscript "Joji Joseph" joji IT
0
 
Dark_KingCommented:
0
 
Dark_KingCommented:
If you dont have "Resource Kit for Windows 2000 " you can download Add Users from here.
http://www.dynawell.com/support/Reskit/win2k.asp
0
 
Dark_KingCommented:
Sorry for the wrong writing in last post.

If you don’t find your "Resource Kit for Windows 2000" you can download Add Users from here.
http://www.dynawell.com/support/Reskit/win2k.asp
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now