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 (0×00000021)
  • MAPI_AB (0×00000022)
  • MAPI_AB_PROVIDER (0×00000023)
  • MAPI_TRANSPORT_PROVIDER (0×00000024)
  • MAPI_SPOOLER (0×00000025)
  • MAPI_PROFILE_PROVIDER (0×00000026)
  • MAPI_SUBSYSTEM (0×00000027)
  • MAPI_HOOK_PROVIDER (0×00000028)

There’s a lot that can be said about any of those, however the one we care about is none of the above. We actually want the one provider that doesn’t have a resource type set.

If you’re hitting the provider up with straight-up MAPI then you want the provider that returns 0x8004010F (MAPI_E_NOT_FOUND). If you’re using Profman.dll or something else to make your life easier, than the value for the provider we care about will most like be 0.

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.

Matt Weber

I'm the the Senior Software Architect at Emergingsoft where I lead the software development team. I am also the owner of this website. I enjoy well-designed code, independent thought, and the application of rationality in general. You can reach me at matt@badecho.com.

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

 
   
© 2012-2013 Matt Weber. All Rights Reserved. Terms of Use.