CDOEXM IDataSource.Open returns 0x8000FFFF when trying to connect to an Exchange server

This is one of those issues that seems that it could be related to any array of issues, and really can only resolved by debugging into a local repro of the problem.  In this case we were trying to open a connection to an Exchange server with CDOEXM to do some typical management work with the server.  What happened in this this particular case is that the following error was returned when trying to open a connection using the IExchangeServer Interface to the Exchange server.  The error that we received:

0x8000FFFF - E_UNEXPECTED

Here's a simple script that demonstrates the problem:

Dim objExchangeServer
Set objExchangeServer= CreateObject("CDOEXM.ExchangeServer")
objExchangeServer.DataSource.Open("MyExchangeServerName")

 ... your other logic here ...

 

Cause:

When our script here is doing the Datasource.open(“MyExchangeServerName”) the CDOEXM code that is being used is doing some LDAP queries behind the scenes against the AD, this is all in preparation to connecting to the requested Exchange server. What happens when we get this 0x8000FFFF error returned, the LDAP query that CDOEXM used returns us two objects.  This then indicates that we have two Exchange servers or other type of naming conflict in this ORG.  And for CDOEXM to properly connect to the Exchange in this instance we can only have one item returned to CDOEXM from the LDAP query.

So this means that we probably have one of the two items existing in this ORG:

> 2 Exchange Servers with the same name, possible but unlikely.

> A system Policy defined that has the same name as the Exchange server that we are trying to connect to with the CDOEXM code.

In this case it was a system Policy that was defined in the ORG with the same name.  Merely, going to the System Polices node and renaming the policy to something other then the name of the Exchange server allow the query to execute properly.

So how do you tell if this is the issue here?  

The best way to confirm this is to use LDP to query the AD using the same query that CDOEXM is going to do to see if we get more than one result returned.  Do the following steps and query in the LDP tool and examine the responses that are returned:

Launch LDP (Start --> Run --> LDP)

Connection Menu --> Connect...

Connection Menu --> Bind...

Browse Menu --> Search

In the Search dialog:

=============================================================

In "Base Dn", enter: Select the second entry in the list.

In "Filter", enter:     "(&(objectClass=msExchExchangeServer)(cn=<Exchange Servername here>))"

For "Scope", select: Subtree

Choose "Run" and see how many results you get.

You can also do the following search:

=============================================================

In "Base Dn", remove the text, so this textbox is empty.

In "Filter", enter:     "(&(objectClass=msExchExchangeServer)(cn=<Exchange Servername here>))"

For "Scope", select: Base

 

Choose "Run" and see how many results you get.  For CDOEXM to properly do the Open method, we should only get one item returned here.

For more information on the LDP tool:

224543  Using Ldp.exe to Find Data in the Active Directory

https://support.microsoft.com/default.aspx?scid=kb;EN-US;224543

 Note: From what I've seen this is not an issue with Exchange 2003 server.