Re: Create Multiple Accounts




Babu VT wrote:
Hi Sam,

Check this out
http://www.activexperts.com/activmonitor/windowsmanagement/adsi/samples/#file006.htm

rgds
Babu

"Sam" <Sam@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:40C9E836-3859-474F-8649-425F742E9D7E@xxxxxxxxxxxxxxxx
I'm trying to create multiple accounts in an OU called 'Visitors' in a
child
domain called sub.local.net bit I'm not entirely sure how to call up the
child domain. I'm working with:

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

Set objContainer = GetOject("LDAP://cn=Visitors,"; &_
objRootDSE.Get("defaultNamingContext"))

For i = 1 To 125
Set objLeaf = objContainer.Create("User", "cn=GuestAcc" & i)
objLeaf.Put "SAMAccountName", "GuestAcc" & i
objLeaf.SetInfo
Next

WScript.Echo "125 User accounts created"


Also, I'd like to be able to set the account password & Home directory if
possible. If anybody with a little more experience could shed some light
on
this, pointing me in the right direction or direct me to somewhere with
some
documentation covering the basics of AD scripting I'd be much
appreciative.

Cheers.

That's a good link, and a good start, but here's where some MS 'DOS'
combined with some VBScript makes everything easier.

Disclaimer: ComputerPerformance.co.uk is where I got all my help with
this. They're a treasure trove of AD scripting info!

First, you need to create a .CSV file (Comma Separated Value; use Excel
to create it) The following fields need to be entered in the cells
along the top as listed:

givenName
SN
displayName
sAMAccountName
userPrincipalName
objectClass
userAccountControl
DN

Then, for each new user account, fill in the information directly below
each 'title' cell (I'm just showing examples below):

givenName = John
SN = Doe
displayName = John Doe
sAMAccountName = doejohn
userPrincipalName = doejohn@xxxxxxxxxx
objectClass = user
userAccountControl = 514
DN = cn=John Doe,ou=NewUsers,dc=Domain,dc=com

Note: objectClass and userAccountControl will always stay the same.
The other fields will obviously be different per user account.

(If, for example, you're creating some sort of guest accounts, and ONLY
need a username created, you can strip out 'givenName', 'SN', and
'displayName'. However, to make sure the script works, just fill in
all the fields.)

And finally for the CSV file, I recommend saving a 'template' with just
the 'title' fields, and making it read-only. That way you never mess
with your format when you do a new batch of users.

Now, run the following .bat (or CMD line) command:

csvde -i -f yourfile.csv

This will create each user account in the OU you designated via the
'DN' field of the .CSV file. Finally, you wanted to change the
password for the accounts. This VBScript will do that (as well as
enable the account, since the CSVDE command creates the accounts as
disabled):

'SetPwd.vbs
'VBScript to reset passwords, enable accounts, and set 'chg pwd at next
logon', by cycling through a named OU
'credited to: Guy Thomas at
http://computerperformance.co.uk/ezine/ezine22.htm
'modified by: Eric C.
'----------------------------------------------------------------------------------------

Option Explicit
Dim objOU, objUser, objRootDSE
Dim strContainer, strLastUser, strDNSDomain
Dim intCounter, intAccValue, intPwdValue
Set objRootDSE = GetObject("LDAP://RootDSE";)
strDNSDomain = objRootDSE.Get("DefaultNamingContext")
strContainer = "OU=NewUsers,"
intAccValue = 544
intPwdValue = 0
strContainer = strContainer & strDNSDomain
set objOU = GetObject("LDAP://"; & strContainer)
intCounter = 0
For each objUser in objOU
If objUser.class = "user" then
objUser.SetPassword "<password>"
objUser.SetInfo

objUser.Put "userAccountControl", intAccValue
objUser.SetInfo

objUser.Put "pwdLastSet", intPwdValue
objUser.SetInfo
intCounter = intCounter + 1
strLastUser = objUser.Get ("name")
End If
Next
WScript.echo intCounter & "Users enabled, pwds set, and must chg pwd at
next logon. Value " _
& strLastUser & intAccValue
WScript.quit

The only thing you should have to change in the VBScript is
strContainer = "OU=NewUsers,"< to point to the OU where you put the new accounts.

Hope this helps out!

-Eric

.



Relevant Pages

  • Re: Create Multiple Accounts
    ... WScript.Echo "125 User accounts created" ... combined with some VBScript makes everything easier. ... The other fields will obviously be different per user account. ... Dim intCounter, intAccValue, intPwdValue ...
    (microsoft.public.windows.server.scripting)
  • Re: Outlook Express, Multiple User Accts, Home Computer, CPU Maxes
    ... Frequently perform a manual compact of all OE folders while "working ... Do not cancel Automatic Compacting, should it occur, and do not attempt ... BUT I can open OE as the Admin User account and it works? ... Try one or more of the mail accounts in a new Named ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • Re: Cannot access some web sites
    ... Have you tried creating a new user account? ... one or two user accounts. ... > Turned off Norton AV ... >> Enable the Windows firewall and disable the Norton firewall. ...
    (microsoft.public.windows.inetexplorer.ie6.browser)
  • Re: Migrating nt4 accounts/computers to win2kAD
    ... > win2k domain used primarily for email. ... > profiles and migrate any other system and computer accounts needed. ... > have kept the user account information and passwords the same in both ... Which of the NT4 system accounts, if any, will we need to migrate? ...
    (microsoft.public.win2000.active_directory)