|
1
30th March 05:19
External User
|
HrFindExchangeGlobalAddressList fails after upgrade to Exchange 20
I am having a problem with a call to HrFindExchangeGlobalAddressList on
Windows 2003 servers running Exchange 2003. It runs successfully on Windows
2000 servers running Exchange 2000. The HrFindExchangeGlobalAddressList call
is failing with an "Unspecified error" (0x80004005). I have included the
sample code I am using:
#include <windows.h>
#include <mapidefs.h>
#include <mapitags.h>
#include <addrlkup.h>
#include <mapiutil.h>
#include <mapiguid.h>
HRESULT GetGALContents ()
{
ULONG cbeid = 0L;
LPENTRYID lpeid = NULL;
HRESULT hRes = S_OK;
ULONG ulObjType;
LPMAPICONTAINER lpGAL = NULL;
LPADRBOOK m_pAddrBook = NULL;
LPMAPISESSION pSession;
TCHAR szBuf[200];
if ( FAILED ( hRes = MAPIInitialize( NULL ) ) )
{
wsprintf(szBuf, "MAPIInitialize failed");
MessageBox( NULL, szBuf, "Error", MB_OK );
goto Quit;
}
if ( FAILED ( hRes = MAPILogonEx( 0, NULL, NULL,
MAPI_USE_DEFAULT | MAPI_NEW_SESSION | MAPI_EXTENDED | MAPI_NO_MAIL,
&pSession ) ) )
{
wsprintf(szBuf, "MAPILogonEx failed");
MessageBox( NULL, szBuf, "Error", MB_OK );
goto Quit;
}
if ( FAILED ( hRes = pSession->OpenAddressBook( 0L,
NULL,
AB_NO_DIALOG,
&m_pAddrBook ) ) )
{
wsprintf(szBuf, "OpenAddressBook failed");
MessageBox( NULL, szBuf, "Error", MB_OK );
goto Quit;
}
if ( FAILED ( hRes = HrFindExchangeGlobalAddressList( m_pAddrBook,
&cbeid,
&lpeid ) ) )
{
wsprintf(szBuf, "HrFindExchangeGlobalAddressList failed");
MessageBox( NULL, szBuf, "Error", MB_OK );
goto Quit;
}
if(FAILED(hRes = m_pAddrBook->OpenEntry((ULONG) cbeid,
(LPENTRYID) lpeid,
NULL,
MAPI_BEST_ACCESS,
&ulObjType,
(LPUNKNOWN *)&lpGAL)))
{
wsprintf(szBuf, "OpenEntry failed");
MessageBox( NULL, szBuf, "Error", MB_OK );
goto Quit;
}
if ( ulObjType != MAPI_ABCONT )
{
wsprintf(szBuf, "ObjType failed");
MessageBox( NULL, szBuf, "Error", MB_OK );
goto Quit;
}
return hRes;
Quit:
if ( NULL != lpGAL)
{
lpGAL -> Release ( );
lpGAL = NULL;
}
return hRes;
}
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
LPVOID lpMsgBuf;
HRESULT hRes = S_OK;
hRes = GetGALContents();
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
hRes,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0, NULL );
MessageBox( NULL, (LPCTSTR)lpMsgBuf, "MAPI test", MB_OK );
LocalFree(lpMsgBuf);
return 0;
}
|