'Using Site server objects, generate a GUID so the new user has a
'unique ID
Set oGuidGen = CreateObject("Membership.GuidGen.1")
strGuid = oGuidGen.GenerateGuid
'Create an object the points to the LDAP accessible container that your
'user will reside in
Set oADsContainer = _ GetObject("LDAP://SiteServer:1050/o=Sendmail/ou=Members")
'Create a new hard coded account in this container called Sean
Set oADsNewUser = oADsContainer.Create("member", "cn=Sean"))
'Set the property of password to "Password"
oADsNewUser.Put "userPassword", cStr("Password")
'Set the property of the first name
oADsNewUser.Put "givenName", cStr("Sean")
'Set the property of the last name
oADsNewUser.Put "sn", cStr("Mccormick")
'Set the property of underwear choice. This is an example of how to
'use an extended schema of a Site Server P & M database.
oADsNewUser.Put "undies", cStr("boxers")
'Set the property of email address
oADsNewUser.Put "mail", cStr("mccormick@home.com")
'Store the name of the Exchange server where this new mailbox
'resides in the rarely used property of userComment. If you want to use
'the userComment property to store a user comment, then choose another
'property that is not used or extend the Site Server LDAP Schema to
'include a "MailboxServer" property.
oADsNewUser.Put "userComment", cStr("ExchangeServer")
'Set the property of the account GUID
oADsNewUser.Put "GUID", CStr(strGuid)
'Save all information and create the account
oADsNewUser.SetInfo
Figure 3 Creating an Exchange Mailbox
'Create an instance of the AcctCrt.DLL that allows us to access the NT
'SAM to retrieve Security IDs
Set mntAcct = CreateObject("MSExchange.AcctMgmt.1")
'Get the Security ID for the user ID that all mailboxes are
'associated with and store it in varSecurityID
Call mntAcct.GetSidFromName("Springfield", "Homer", varSecurityID)
'Create an object that points to the Exchange directory container that
'mailbox will be created in
Set recipcont_obj = _
GetObject("LDAP://ExchangeServer/o=TestOrg/ou=TestSite/cn=Recipients")
'Create the mailbox via LDAP in the above container...
Set recip_obj = recipcont_obj.Create("organizationalPerson", "cn=Sean")
'Set the manditory Exchange mailbox properties to make the mailbox
'functional
'Set the mail preference option property
recip_obj.Put "mailPreferenceOption", 0
'Set the property of Last Name
recip_obj.Put "sn", (CVar(LastName))
'Set the property Mailbox Name
recip_obj.Put "cn", (Cvar("Sean"))
'Set the property First Name
recip_obj.Put "givenName", (Cvar("Sean"))
'Set the property of mailbox Alias
recip_obj.Put "uid", (Cvar("Sean"))
'Set the property of the mailbox Home MTA
recip_obj.Put "Home-MTA", (CVar("cn=Microsoft _
MTA,cn=ExchangeServer,cn=Servers,cn=Configuration,ou=TestSite, _
o=TestOrg))
'Set the property of the mailbox Home MDB
recip_obj.Put "Home-MDB", (CVar("cn=Microsoft Private MDB, _
cn=ExchangeServer,cn=Servers,cn=Configuration,ou=TestSite, _
o=TestOrg))
'Set the property of what NT account this mailbox is associated with
recip_obj.Put "Assoc-NT-Account", (CVar(varSecurityID))
'Set the property of the mailbox SMTP Address
recip_obj.Put "mail", (CVar("Sean@MyEmailDomain.Com"))
'Set the property of the internally used X400 Address
recip_obj.Put "textEncodedORaddress", (CVar("c=US;a= ;p=TestOrg; _
o=TestSite;s=McCormick;g=Sean"))
'commit the contents of the ADSI object and save the new mailbox to
'the Exchange directory
recip_obj.setinfo