HrMailboxLogon privs...

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance




Do anyone know the minimum privledges requires to use HrMailboxLogon? The
following code succeeds with the HrMailboxLogon() call, but later fails when
trying to open the default receive folder...

HRESULT hRes;
LPMAPISESSION lpMAPISession = NULL;
LPMDB lpMDB = NULL;
LPMDB lpUserMDB = NULL;
LPMAPIFOLDER lpInboxFolder = NULL;
LPSPropValue tmp = NULL;

MAPIINIT_0 MAPIInit;
MAPIInit.ulFlags = 8;
MAPIInit.ulVersion = MAPI_INIT_VERSION;

hRes = MAPIInitialize(&MAPIInit);

if (FAILED(hRes)) goto quit;
hRes = MAPILogonEx(0,
"blahblah",
"blah",
MAPI_NO_MAIL |
MAPI_EXTENDED |
MAPI_NEW_SESSION |
MAPI_EXPLICIT_PROFILE,
&lpMAPISession);
if (FAILED(hRes)) goto quit;

// First locate the primary user information store provider.
hRes = HrOpenExchangePrivateStore(lpMAPISession, &lpMDB);
if (FAILED(hRes)) goto quit;

//LPMDB lpUserMDB = NULL;
// logon to mailbox
hRes = HrMailboxLogon(
lpMAPISession,
lpMDB,
(LPSTR)"/o=emc/ou=north
america/cn=configuration/cn=servers/cn=archexlab1/cn=Microsoft Private MDB",
(LPSTR)"/o=EMC/ou=North America/cn=Recipients/cn=ARCHEXLAB1JN1",
&lpUserMDB);
if( FAILED(hRes) )
printf("Logon to mailbox failed. Res %x", hRes);

hRes = HrGetOneProp(
lpUserMDB,
PR_DISPLAY_NAME,
&tmp);
if (FAILED(hRes)) goto quit;

printf("Res: %x Store display name '%s'\n",hRes, tmp->Value.lpszA);
// This call succeeds but the property is empty


hRes = OpenInbox(
l pUserMDB,
&lpInboxFolder);
if (FAILED(hRes)) goto quit;

quit:
if (tmp) MAPIFreeBuffer(tmp);
UlRelease(lpInboxFolder);
UlRelease(lpMDB);
UlRelease(lpMAPISession);
MAPIUninitialize();
if (FAILED(hRes))
{
printf("Failed with hRes of %x\n",hRes);
}
printf("Hit any key to continue\n");
while(!_kbhit()){ Sleep(50);};

}

STDMETHODIMP OpenInbox(
LPMDB lpMDB,
LPMAPIFOLDER *lpInboxFolder)
{
ULONG cbInbox;
LPENTRYID lpbInbox;
ULONG ulObjType;
HRESULT hRes = S_OK;
LPMAPIFOLDER lpTempFolder = NULL;

*lpInboxFolder = NULL;

//The Inbox is usually the default receive folder for the message store
//You call this function as a shortcut to get it's Entry ID
hRes = lpMDB->GetReceiveFolder(
NULL, //Get default receive folder
NULL, //Flags
&cbInbox, //Size and ...
&lpbInbox, //Value of the EntryID to be returned
NULL); //You don't care to see the class returned
if (FAILED(hRes)) goto quit;

hRes = lpMDB->OpenEntry(
cbInbox, //Size and...
lpbInbox, //Value of the Inbox's EntryID
NULL, //We want the default interface
(IMAPIFolder)
MAPI_BEST_ACCESS, //Flags
&ulObjType, //Object returned type
( LPUNKNOWN *) &lpTempFolder); //Returned folder

if (FAILED(hRes))
{
printf("Opening inbox folder failed. hr = %d\n", hRes); *******
THis call failed with MAPI_E_NOT_FOUND
goto quit;
}

//Assign the out parameter
*lpInboxFolder = lpTempFolder;

//Always clean up your memory here!
quit:
MAPIFreeBuffer(lpbInbox);
return hRes;
}


.