Creating mailboxes with a VBScript
Two ways of creating users with mailboxes
There are two possible strategies, create users from scratch, or add mailbox
attributes to existing accounts.
Strategy 1
Create a new user complete with mailbox. Build the complete user object
from scratch, the result will be a mail-enabled user account. For strategy
1,
most of the work is done by CSVDE and Excel. Create a spreadsheet and put
the LDAP fields in the top row.
Part a)
In addition to the usual LDAP fields: dn, sAMAccountName, sn, givenName you
need 5 extra Exchange mailbox fields.
Mail specific LDAP attributes
msExchHomeServerName
mail
mailnickname
homeMDB
mDBUseDefaults
Import your spreadsheet with CSVDE -i -filename.csv -k
Part b)
Once the user has been created, then you need to
set the password and activate the account. See script below.
' Set Password.vbs
' VBScript to Set Passwords by cycling through a named OU
' Author Guy Thomas http://computerperformance.co.uk/
' Version 2.9 - March 10th 2004
' -----------------------------------------------------------------'
Option Explicit
Dim objOU, objUser
Dim strContainer, strLastUser, intCounter
strContainer = "ou=St Hilary, dc=CPEXCH,dc=com"
set objOU =GetObject("LDAP://" & strContainer )
intCounter = 0
For each objUser in objOU
If objUser.class="user" then
objUser.SetPassword "P@ssw0rd"
objUser.SetInfo
objUser.Put "userAccountControl", "512"
ObjUser.SetInfo
intCounter = intCounter +1
strLastUser = objUser.Get ("name")
End if
next
WScript.Echo intCounter & " Passwords change. Last user " _
& strLastUser
WScript.Quit
|