You are currently offline, waiting for your internet to reconnect

How To Open the Global Profile Section

This article was previously published under Q188482
This article provides code that demonstrates how to open the Global ProfileSection and retrieve one of the properties that exist in this section. Italso provides a comprehensive list of properties that exist in the globalprofile section. The key to this is to request the profile section that haspbGlobalProfileSectionGuid for its unique identifier. This is a constantthat is defined in the Edkmdb.h file.
It may be necessary to retrieve or modify the values of properties thatexist in the Global Profile Section of a Messaging Application ProgrammingInterface (MAPI) profile. A global profile section exists for each profilethat uses the Microsoft Exchange Messaging Service. This "global section"is used to store common data, plus individual sections for the transportprovider, one store provider for the user, one store provider for thepublic store, and one store provider for each additional mailbox to whichthe user has delegate access.

The following code is an example of how to open the Global Profile Sectionof a MAPI profile and how to extract the PR_PROFILE_HOME_SERVER property:

Sample Code

   #include <objbase.h>   #include <mapix.h>   #include <mapidefs.h>   #include <mapiguid.h>   #include <edk.h>   #include <edkmdb.h>   HRESULT GetServerName()   {     HRESULT hRes = S_OK;   // HRESULT returned by this method     LPPROFADMIN pAdminProfiles = NULL; // Pointer to IProfAdmin object     LPSERVICEADMIN pSvcAdmin = NULL;  // Pointer to IServiceAdmin object     LPPROFSECT pGlobalProfSect = NULL; // Pointer to IProfSect object     LPSPropValue pProps = NULL; // Pointer to PropValue                                // PR_PROFILE_HOME_SERVER     char szServerName[256]; // String that will contain the server name     // If your app doesn't already initialize the MAPI subsystem,     // do it now.     if ( FAILED ( hRes = MAPIInitialize ( NULL ) ) )        return hRes;     // Get a Profile admin object     if ( FAILED ( hRes = MAPIAdminProfiles ( 0L, &pAdminProfiles ) ) )        goto CleanUp;     // Get a ServiceAdmin object     if ( FAILED ( hRes = pAdminProfiles -> AdminServices (                                           "<profile name>",                                           NULL,                                           0L,  // Your app's window handle                                           0L,                                           &pSvcAdmin ) ) )       goto CleanUp;      // Get the Global Profile Section by calling      // IServiceAdmin::OpenProfileSection use pbGlobalProfileSectionGuid      // defined in EDKMDB.H as the entry ID to request      // The default return is an IProfSect interface.      if ( FAILED ( hRes = pSvcAdmin -> OpenProfileSection (                                  (LPMAPIUID)pbGlobalProfileSectionGuid,                                  NULL,                                  0L,                                  &pGlobalProfSect ) ) )         goto CleanUp;      // Call HrGetOneProp to get PR_PROFILE_HOME_SERVER      if ( FAILED ( hRes = HrGetOneProp ( pGlobalProfSect,                                          PR_PROFILE_HOME_SERVER,                                          &pProps ) ) )         goto CleanUp;      // Set Server name pointer to string equal to value returned from      // HrGetOneProp      strcpy ( szServerName, "PR_PROFILE_HOME_SERVER == " );      strcat ( szServerName, pProps -> Value.lpszA );      // Replace window handle param with your application's window handle      MessageBox ( 0L, szServerName, "Exchange Server Name", MB_OK );      CleanUp:      // Free all memory allocated by any MAPI calls      if ( NULL != pAdminProfiles )         pAdminProfiles -> Release ();      if ( NULL != pSvcAdmin )         pSvcAdmin -> Release ( );      if ( NULL != pGlobalProfSect )         pGlobalProfSect -> Release ( );      if ( NULL != pProps )         MAPIFreeBuffer ( &pProps );      pSvcAdmin = NULL;      pGlobalProfSect = NULL;      pProps = NULL;      pAdminProfiles = NULL;      // Return the HRESULT to the calling function      return hRes;      }				
NOTE: Be sure to include the following libraries in the link process:
Kernel32.lib, User32.lib, Msvcrt.lib, Mapi32.lib, Edkguid.lib, Edkutils.lib, Edkmapi.lib, Edkdebug.lib.
You also need to check the option to ignore default libraries in thegeneral project settings of the link process. To do this, choose Settingsfrom the Project menu, click the Link tab, set the category box to Generaland than select the desired option.

The following is a list of properties that exist in the Global ProfileSection:
Please read the Platform Software Developers Kit for more information onthese and other properties.
kbDSupport kbMsg kbEDK kbEDK400 kbEDK500 kbMAPI100 kbMAPI EDKAPI EMAPI

Article ID: 188482 - Last Review: 08/18/2005 18:01:05 - Revision: 2.5

  • Microsoft Office Outlook 2007
  • Microsoft Exchange Development Kit 5.5
  • Microsoft Exchange Development Kit 5.5
  • Microsoft Messaging Application Programming Interface
  • kbapi kbhowto kbmsg KB188482
body>s://" '="">