Outlook Profile Management II
Aug 2
2011
My previous article covered how to figure out which account Outlook was operating under in circumstances where profiles with multiple Exchange accounts were active.
I ended with showing you how to get the profile section of the message service of the active Exchange account. However, if you actually want to read the juicy configuration options, like `PR_PROFILE_CONFIG_FLAGS`, you’ll need to dig a bit deeper. Although some configuration settings are available at the message service profile section level, that specific profile section isn’t actually the “new” global profile section in 2010.
So where’s my global profile section!?
In order to find the “new” global profile section in 2010, you need to look through that message service’s service providers. A single provider will have a profile section that will contain all of the configuration settings previously available from the global profile section. I’m referring to this section as the “new” global profile section because I have yet to find a term from Microsoft that describes the profile section containing all of the configuration settings previously found in the global profile section. Again, what you are using to access the profile system doesn’t really matter, for purposes of brevity I assume you’re using .NET and Profman.dll to do so. So, if you look at where we left off, we ended with an IService object. This is the active message service. You can see that IService exposes a Providers property, which is the collection of all of the service providers found below the message service.Resource Type Values
Each IProvider belonging to this collection will have a number of properties. The one of interest here is ResourceType, otherwise known as `PR_RESOURCE_TYPE` (0x3E030003), which is an indicator of the...you guessed it...service provider type! Its value can be one of the following:- MAPI_STORE_PROVIDER (0x00000021)
- MAPI_AB (0x00000022)
- MAPI_AB_PROVIDER (0x00000023)
- MAPI_TRANSPORT_PROVIDER (0x00000024)
- MAPI_SPOOLER (0x00000025)
- MAPI_PROFILE_PROVIDER (0x00000026)
- MAPI_SUBSYSTEM (0x00000027)
- MAPI_HOOK_PROVIDER (0x00000028)
Example (continuing from code in last article)
Please be aware the following code, for the sake of brevity, again does not follow the absolute best practices for COM interop object lifetime management. I have other articles on that, etc.
IProvider provider = null;
for (int k = 1; k <= service.Providers.Count; k++)
{
//”service” is the active message service we found in the last article
provider = service.Providers.Item[k];
if (provider.ResourceType == 0)
break;
}
//This provider should contain the section we want (the “new”
//global profile section).
if (null == provider)
return;
IProfSect newGlobalSection = provider.ProfSect;
object configFlags = newGlobalSection.Item[0x66010003];
//This should give you PR_PROFILE_CONFIG_FLAGS.
That’s it.
