Some customers have encountered problems with the
CreateMailbox function when they try to create mailboxes for existing users in Active Directory. These problems occur on servers that are running either Exchange 2000 Server or Exchange Server 2003. When they try to create mailboxes, they receive one of the following error messages:
Error -2147467259 There is no Connection Agreement configured to export this recipient to the Exchange 5.5 server.
ID no: c1034a1b Microsoft CDO for Exchange Management
Error -2147016646 The server is not operational Facility: Win32
ID no: 8007203a Microsoft CDO for Exchange Management
These customers have been able to work around this problem by binding explicitly to a domain controller.
Sample code
The following Microsoft VBScript sample code shows how to programmatically create a mailbox for an
existing user by using CDOEXM. You must run this sample
code on a computer that has the Microsoft Exchange System Manager Tools
installed.
- Create a domain user. However, do not create an Exchange mailbox
for the domain user.
- Create a .vbs file
- Add the following sample code to the .vbs file.
Dim oIADSUser
Dim oMailbox
Set oIADS = GetObject("LDAP://RootDSE")
strDefaultNC = oIADS.Get("defaultnamingcontext")
'MsgBox FindAnyMDB("CN=Configuration," & strDefaultNC)
'TODO: Use the newly created domain user account to replace the "UserName".
Set oIADSUser = GetObject("LDAP://CN=UserName,CN=Users," & strDefaultNC)
If oIADSUser Is Nothing then
MsgBox "The oIADSUser is Nothing."
Else
MsgBox "The oIADSUser is created successfully."
End If
Set oMailBox = oIADSUser
oMailbox.CreateMailbox FindAnyMDB("CN=Configuration," & strDefaultNC)
oIADSUser.SetInfo
Function FindAnyMDB(strConfigurationNC)
Dim oConnection
Dim oCommand
Dim oRecordSet
Dim strQuery
' Open the Connection.
Set oConnection = CreateObject("ADODB.Connection")
set oCommand = CreateObject("ADODB.Command")
Set oRecordSet = CreateObject("ADODB.Recordset")
oConnection.Provider = "ADsDSOObject"
oConnection.Open "ADs Provider"
' Build the query to find the private MDB.
strQuery = "<LDAP://" & strConfigurationNC & ">;(objectCategory=msExchPrivateMDB);name,adspath;subtree"
oCommand.ActiveConnection = oConnection
oCommand.CommandText = strQuery
Set oRecordSet = oCommand.Execute
' If you have an MDB, return the first one.
If Not oRecordSet.EOF Then
oRecordSet.MoveFirst
FindAnyMDB = CStr(oRecordSet.Fields("ADsPath").Value)
Else
FindAnyMDB = ""
End If
'Clean up.
oRecordSet.Close
oConnection.Close
Set oRecordSet = Nothing
Set oCommand = Nothing
Set oConnection = Nothing
End Function
- Search for the TODO text string in the code, and then
modify the code for your environment.
- Run the sample code.