Q: Scripted way to create mailbox for a user of other then Exchagne 2003 domain
Hello Everyone! Seeking for help: How to programaticaly (vbs or vb6) create a mailbox for a user account located in other than Exchange 2003 Server active directory domain (W2003)?More details:The Exchange 2003 server is a member of domain1, a user I would like to give new mailbox is a member of domain2. Both domains are at the same forest, they are built as child domains to the forest root domain (CORP1). Where domain1 trusts domain2 and vice-versa.The Exchange organization is shared among whole forest domains. The person who is runing the script has sufficient privileges to operate in both domains and manage Exchange mailboxes (Exchange Full Admin for domain1)Now I create a user account in domain2 (using ADSI) then I want to create a mailbox for the user (CDO/CDOEXM), the mailbox should be located at the Exchange 2003 server from domain1. Unfortunately the script I use was failed at the stage where mailbox is about to be created, with error message like:Facility: LDAP ProviderError - 2147016656... There is no such object on the server.ID no: 80072030Microsoft CDO for Exchange Management...By the way, there is no problem creating mailbox for the user by standard GUI using ADUnC running from domain2 under same admin account.Below the example of code to create a user with mailbox:Function ADSICreateMailBoxRecipient(MDBName As String, _ StorageGroup As String, _ Server As String, _ AdminGroup As String, _ Organization As String, _ MailboxADPath As String, _ emailname As String, _ name As String, _ Display As String, _ LegDN As String, _ usrDescript As String) Dim objUser As IADsUserDim objContainer As IADsContainerDim objMailbox As CDOEXM.IMailboxStoreDim recipname As String, recip As Stringrecip = "CN=" & name' get the containerSet objContainer = GetObject("LDAP://" + MailboxADPath)' create a recipientSet objUser = objContainer.Create("User", recip)objUser.Put "samAccountName", nameobjUser.Put "userPrincipalName", nameobjUser.Put "MailNickname", emailnameobjUser.Put "displayName", DisplayobjUser.SetInfoobjUser.Put "legacyExchangeDN", LegDNobjUser.Put "Description", usrDescriptobjUser.SetInfoobjUser.SetPassword RandPass() ' here we call external functionobjUser.AccountDisabled = FalseSet objMailbox = objUser'Create a mailbox for the recipient'You cannot create a mailbox using ADSI, so use CDOEXMstrHomeMDBURL = "LDAP://CN=" + MDBName + _ ",CN=" + StorageGroup + _ ",CN=InformationStore" + _ ",CN=" + Server + _ ",CN=Servers" + _ ",CN=" + AdminGroup + _ ",CN=Administrative Groups" + _ ",CN=" + Organization + _ ",CN=Microsoft Exchange,CN=Services" + _ ",CN=Configuration,DC=corp,DC=CORP1,DC=net" objMailbox.CreateMailbox strHomeMDBURLobjUser.Put "legacyExchangeDN", LegDN 'Add here to prevent LegacyDN reverting to default name. objUser.SetInfoSet objUser = NothingEnd Function<!--[if !supportLineBreakNewLine]--><!--[endif]--><!--[if !supportLineBreakNewLine]--><!--[endif]-->
March 22nd, 2008 7:24am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics