Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

creating and enabling users at the sametime...?

Status
Not open for further replies.

matrix101

MIS
Jun 5, 2007
60
0
0
US
Hello,

I'm tring to learn how to script and found this script online: It works fine and it creates the users but I would like the users to be enabled as well.

I know there is a command "objuser.acctdisabled = false"
but I don't know if thats the correct syntax or where to place it in the script so it only enables the accts I'm creating.

I appreciate the help.

********************
Set objRootDSE = GetObject("LDAP://rootDSE")

Set objContainer = GetObject("LDAP://cn=Users," & _
objRootDSE.Get("defaultNamingContext"))

For i = 1 To 5
Set objLeaf = objContainer.Create("User", "cn=UserNo" & i)
objLeaf.Put "sAMAccountName", "Train01" & i

objUser.AccountDisabled = FALSE

objLeaf.SetInfo

Next

WScript.Echo "5 Users created."
****************
 
THis is the command I found but not sure how to work it into what I already have. Also not sure if there is a difference between "objuser" and "objleaf"

objUser.AccountDisabled = FALSE

Thanks again!
 
Is there anyway to enable the account and set the password at the sametime the accounts are created? thanks
 
Code:
Set objRootDSE = GetObject("LDAP://rootDSE")

Set objContainer = GetObject("LDAP://cn=Users," & _
objRootDSE.Get("defaultNamingContext"))
 
For i = 1 To 5
   Set objLeaf = objContainer.Create("User", "cn=UserNo" & i)
   objLeaf.Put "sAMAccountName", "Train0" & i
   objLeaf.SetInfo
   objLeaf.SetPassword "Abcd1234"
   objLeaf.SetInfo
   objLeaf.AccountDisabled = FALSE
   objLeaf.SetInfo
Next

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top