Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

How To Use the HrMailboxLogon Function


View products that this article applies to.

This article was previously published under Q203858

↑ Back to the top


Summary

The Exchange Development Kit (EDK) HrMailboxLogon function takes a pair of parameters for both the server name and the mailbox name. The documentation on the HrMailboxLogon function is misleading.

According to the documentation on the HrMailboxLogon function, both the message store (lpszMsgStoreDN) and the mailbox (lpszMailboxDN) parameters are distinguished names, in the form of the following:
/O=Organization/OU=Site/CN=Servers/CN=ServerName/CN=NULL
/O=Organization/OU=Site/CN=Container/CN=MailboxName
However, the last leaf of the message store name parameter cannot be a NULL value. If the HrMailboxLogon function is executed as the documentation suggests, it fails with the following error message:
0x80004005: Unspecified Error

↑ Back to the top


More information

To work around this behavior, the last leaf of the message store must have a string that identifies the store name to be used (for example, "Microsoft Private MDB" or "Microsoft Public MDB"). The lpszMsgStoreDn must be in the following form:
/O=Organization/OU=Site/CN=Servers/CN=ServerName/CN=Microsoft Private MDB
or
/O=Organization/OU=Site/CN=Servers/CN=ServerName/CN=Microsoft Public MDB

The following code demonstrates how to use the HrMailboxLogon to log on a user's mailbox, and then return a pointer to this store.

Sample Code

In the following code, it is assumed that you have a valid lpSession and pointer to the default message store lpmdbDefault (the user's inbox), and that szMailboxDN is already set.
   (...)
   // Gets server distinguished name from current session - from edkutils.h
   hr = HrGetServerDN( lpSession, &lpszServerDN );
   if ( hr != S_OK ) {
       goto CleanUp;
   }
   strcpy(szServerDN, lpszServerDN);
   strcat(szServerDN, "/cn=Microsoft Private MDB");
   // Open user's mailbox using distinguished names
   hr = HrMailboxLogon(
           lpSession,
           lpmdbDefault,
           szServerDN,
           szMailboxDN,
           &lpmdbMailbox);
   if ( hr != S_OK ) {
       goto CleanUp;
   }
   (...)
				

↑ Back to the top


References

For additional information about HrMailboxLogon code samples, click the article numbers below to view the articles in the Microsoft Knowledge Base:
194627� How To Open Mailboxes with Privileged Access
200160� How To Loop Through Mailboxes on Exchange Using GetMailboxTable

↑ Back to the top


Keywords: KB203858, kbmsg, kbhowto, kbdocfix

↑ Back to the top

Article Info
Article ID : 203858
Revision : 5
Created on : 7/13/2004
Published on : 7/13/2004
Exists online : False
Views : 258