VBScript: create Exchange 5.5 mailbox using ADSI and LDAP

For the below script to work, you need the AcctCrt COM components to be installed. You can download this component form the Microsoft site.

strDomainNT4 = "TOOLS4EVER"
strUsername = "avdvorst"
strEx55Server = "EXCHANGE"
strMailboxPath = "DN of your recipient container"
strSite = "Name of site"
strOrg = "Name of organization"

Set objAcctMgmt = CreateObject("MSExchange.AcctMgmt")
'prepare Exchange security descriptor (needs WinNT binding so make sure the user account has been replicated among all DCs
RetVal = objAcctMgmt.GetSidFromName(strDomainNT4, strUsername, arrSID)
RetVal = objAcctMgmt.GenerateSecDescriptor(strDomainNT4, strUsername, arrSD)
'connect to the container where you want the mailbox created
Set objMBContainer = GetObject("LDAP://" & strEx55Server & "/" & strMailBoxPath)
'create the actual mailbox object
Set objMB = objMBContainer.Create("OrganizationalPerson", "cn=" & strUser)
'set the mailbox object properties
objMB.Put "Assoc-NT-Account", (arrSID)
objMB.Put "NT-Security-Descriptor", (arrSD)
objMB.Put "uid", strUsername
objMB.Put "mailNickname", strUsername
objMB.Put "MDB-Use-Defaults", True
objMB.Put "MAPI-Recipient", True
strMDB = "cn=Microsoft Private MDB,cn=" & strEx55Server & _
",cn=Servers,cn=Configuration,ou=" & strSite & ",o=" & strOrg
objMB.Put "Home-MDB", strMDB
strMTA = "cn=Microsoft MTA,cn=" & strEx55Server & _
",cn=Servers,cn=Configuration,ou=" & strSite & ",o=" & strOrg
objMB.Put "Home-MTA", strMTA
objMB.SetInfo

Geschreven door:

Arnout van der Vorst

Arnout van der Vorst is Identity Management Architect bij Tools4ever en al ruim 10 jaar in dienst. Arnout legt zich als Architect toe op het bedenken en ontwikkelen van nieuwe features, oplossingen en diensten van Tools4ever die aansluiten op de vraag uit de markt. Arnout studeerde Hogere Informatica aan de Hogeschool van Utrecht.
Terug