MAPI and Exchange 2013 Public Folders


Prior to Exchange 2013, when Outlook’s emsmdb32 provider would log on to the server, it would get various bits of information back from the server, including information needed to connect to the Public Folder store. The provider would use this information to add the Public Folder store to the profile. This work involved pumping messages and this is where the workaround given here was involved:

http://blogs.msdn.com/b/stephen_griffin/archive/2007/05/30/outlook-2007-public-folders-mapi-and-you.aspx

With Exchange 2013, logon no longer returns any information related to Public Folders. Instead, the information needed to connect to Public Folders is handled through Autodiscover. When we do the initial AutoDiscover for profile creation, we get an entry back indicating that there is a Public Folder mailbox. Here’s what it looked like for my test mailbox:

<PublicFolderInformation>
  <SmtpAddress>TestPFMailbox@tailspintoys.com</SmtpAddress>
</PublicFolderInformation>

We see the name of the Public Folder mailbox is TestPFMailbox. Outlook uses this information to conduct another Autodiscover conversation to get information on the Public Folder mailbox. Essentially, we send a request that looks like this:

<?xml version="1.0" encoding="utf-8"?>
<Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/requestschema/2006">
  <Request>
    <EMailAddress>TestPFMailbox@tailspintoys.com</EMailAddress>
    <AcceptableResponseSchema>http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a</AcceptableResponseSchema>
  </Request>
</Autodiscover>

We get a response back with information on the PF mailbox. Outlook then uses this information to make a call to CreateProvider to actually add the Public Folder store to the profile. CreateProvider takes a set of MAPI properties, whose values were derived from the information in the Autodiscover response. The properties we pass to CreateProvider are all derived from the AutoDiscover response:

Property Source/Value Comment
PR_DISPLAY_NAME_W   Public Folders –%s”, where %s is the value of PR_PROFILE_USER_SMTP_EMAIL_ADDRESS_W. So, for my folder, it would be “Public Folders – sgriffin@tailspintoys.com
PR_PROFILE_USER PR_PROFILE_USER This is the value of PR_PROFILE_USER from the Exchange Profile Section
PR_PROFILE_ALTERNATE_STORE_TYPE "Public" Hardcoded value
PR_EMSMDB_SECTION_UID User’s emsmdbUID This is the GUID of the Exchange Profile Section
PR_PROFILE_SERVER Server from the EXCH node in the Autodiscover response Truncate this value at the first ‘.’ in the Server value. For instance, if Server is “1234…5678@tailspintoys.com”, this value would be “1234…5678@tailspintoys
PR_PROFILE_SERVER_DN ServerDN from the EXCH node in the Autodiscover response  
PR_PROFILE_SERVER_FQDN Server from the EXCH node in the Autodiscover response  
PR_PROFILE_USER_SMTP_EMAIL_ADDRESS_W SMTPAddress from the PublicFolderInformation node in the Autodiscover response  
PR_PROFILE_AUTH_PACKAGE Mapped from AuthPackage from the EXCH node in the Autodiscover response For instance, a value of kerb would translate to RPC_C_AUTHN_GSS_KERBEROS. Special cases include:

Anonymous maps to 0x8000F001
PR_ROH_FLAGS ROHFLAGS_USE_ROH | ROHFLAGS_SSL_ONLY If ServerExclusiveConnect is on, include ROHFLAGS_HTTP_FIRST_ON_FAST | ROHFLAGS_HTTP_FIRST_ON_SLOW

if CertPrincipalName is not none, include ROHFLAGS_MUTUAL_AUTH

PR_ROH_PROXY_SERVER_W Server from the EXPR  node in the Autodiscover response  
PR_ROH_PROXY_AUTH_SCHEME Mapped from AuthPackage from the EXPR node in the Autodiscover response For instance, a value of Basic would translate to ROHAUTH_BASIC
PR_ROH_PROXY_PRINCIPAL_NAME CertPrincipalName from the EXPR node in the Autodiscover response  

I’ve done a bit of hand waiving above, and I’ve likely missed a number of corner cases, but this should be enough for someone to get started. All of this work actually happens in Outlook.exe, so there is no way for external MAPI processes to trigger it (though it’s possible it might happen while using the Outlook Object Model).

 

For more information on the Autodiscover process, see [MS-OXDSCLI]: Autodiscover Publishing and Lookup Protocol. Enjoy!

Comments (12)

  1. Hi Steve, thanks for the information. We've applied this to profiles we're using with downloadable MAPI and it works very nicely for on-premise Exchange but the same set of properties doesn't work for an Exchange Online mailbox – when we log in we get the mailbox but no public folders. Do you expect that to work?

    Thanks,

    Oliver

  2. Stephen Griffin says:

    As I noted, I probably missed a few cases here. I'd suggest letting Outlook configure a profile for that scenario and then take a look at the settings to see how they compared to what you tried to set and to what's in the Autodiscover response. That'll most likely highlight what I missed. If you find out what it is, lemme know and I'll update the article.

  3. Hi Steve, I see that ServerExclusiveConnect is On in EXPR & EXHTTP nodes and Off in EXCH node. I believe the one from EXPR node only should be considered??

  4. supcxc says:

    Hi Steve,

    Our team has been trying to use MAPI to access public folder mailbox in a RDB for a long time. But nothing works.

    Could you please let us know if it's possible at all to use MAPI(e.g. MFCMAPI) to access the public folder mailbox in a RDB? If it's possible, how? Thanks a lot!!!

    Simon

  5. Hugh says:

    I am not able to find the define for PR_PROFILE_ALTERNATE_STORE_TYPE, could you point me to where that is defined or provide the value?

  6. Stephen Griffin says:

    #define PR_PROFILE_ALTERNATE_STORE_TYPE_W PROP_TAG(PT_UNICODE,0x65D0)

  7. Hugh says:

    Thanks Steve, I also cannot find the value for PR_PROFILE_USER_SMTP_EMAIL_ADDRESS_W.

  8. Hugh says:

    The last one I had trouble finding is PR_PROFILE_SERVER_FQDN, if this the same as PR_PROFILE_HOME_SERVER_FQDN PROP_TAG(PT_LONG, 0x662A)

  9. Stephen Griffin says:

    #define PR_PROFILE_USER_SMTP_EMAIL_ADDRESS_W PROP_TAG(PT_UNICODE,0x6641)

    #define PR_PROFILE_SERVER_FQDN PROP_TAG(PT_UNICODE,0x662B)

  10. calonzo says:

    Steve,  I have the same question as supcxc.  If I manually create a profile to access Exchange 2013 Public Folders, can I use MAPI to access it?

  11. Hugh says:

    I have validated that I have all the propTags and values set correctly. They are the same as the ones set by Outlook when it successfully creates the Public Folders provider. When I call CreateProvider I always get back a MAPI_E_NOT_FOUND (0x8004010f) error and the provider is not created. Any suggestions on what I should check. Am I passing the wrong value to the lpszProvider param? I have tried various values there both unicode and ansi.

  12. Konstantin says:

    @supcxc / calonzo

    Have you ever solved it?