Connecting to Recovery Storage Groups using MAPI
Microsoft® Exchange Server 2003 recovery storage groups enable administrators to mount Exchange storage groups restored from backup, and then access the entire storage group, databases, and individual mailboxes. Typically, recovery storage groups are created, mounted and accessed through the Exchange System Manager, and the individual mailboxes are restored using the exmerge utilty. In addition, custom applications can connect to the recover storage group using MAPI
Programmatically Accessing a Recovery Storage Group
The latest version of the edkmdb.h file that first shipped with the Exchange 2003 SDK March 2003 includes the CONNECT_RESTORE_DATABASE entry in PR_PROFILE_CONNECT_FLAGS. The edkmdb.h file installed by the SDK is located by default in C:\Program Files\Exchange SDK\SDK\Include. The CONNECT_RESTORE_DATABASE flag has the value 128 decimal, or 0x40 hex. You use the PR_PROFILE_CONNECT_FLAGS in calls to the IMAPISession::OpenMsgStore function.
To logon to an individual mailbox, call the HrMailboxLogon MAPI function. In the lpMDB parameter to the HrMailboxLogon function call, pass the pointer returned by the successful OpenMSGStore call.
Requirements for Accessing Recovery Storage Groups
To successfully log on to a mailbox in a recovery storage group, the original mailbox must also be present in the database, and the Microsoft Active Directory® entry for the user must be correctly connected to the original mailbox.
Public Folder databases cannot be accessed using a recovery storage group.
Deleted mailboxes cannot be recovered by recovery storage groups. When a new mailbox is created, Exchange stamps the mailbox with a unique identifier in the msExchMailboxGUID attribute in Active Directory. Because the user mailbox must have the samve msExchMailboxGUID value as the mailbox in the recovery storage group, if the user mailbox has been deleted, that value will not be the same. Recreating the user mailbox will generate a different msExchMailboxGUID value.
To access a user mailbox in a recovery storage group, the msExchOrigMDB value of the recovery storage group must be the same as where the user mailbox currently exists. If the user mailbox has been moved to a different storage group, you won't be able to access the mailbox in the recovery storage group. One way to remedy this is to move the user mailbox back to the original storage group. A potentially easier method is to change the msExchOrigMDB attribute on the recovery storage group so that it indicates the storage group where the user mailbox was moved. If you've changed the recovery storage group msExchOrigMDB attribute, you will be able to access mailboxes in the recovery storage group belonging to only those users that were moved to the value to which you changed msExchOrigMDB. Remember to set the recovery storage group msExchOrigMDB value to the correct value for each mailbox your application must access.
After your application has finished accessing mailboxes in the recovery storage group, the application should unmount and possibly remove the recovery storage group. If a recover storage group exists, it may be overwritten by a subsequent restore operation.
The Microsoft article # 824126 contains good information about these properties and working with recovery storage groups. The KB article describes how to use the exmerge.exe recovery tool, which uses MAPI to connect to the recovery storage group.