INFO: IMAPITable::Restrict Returned Rows Limitation in Exchange Address Book

This article has been archived. It is offered "as is" and will no longer be updated.
Summary
The Microsoft Exchange Server Address Book has always limited the size ofrestrictions. For systems without Outlook security patch, the default maximum row restriction is 16000 rows for 32-bit clients and 4000 entries for 16-bit clients. For systems with Outlook security patch, the default maximum row restriction is 5000 rows for 32-bit clients and 4000 entries for 16-bit clients. IMAPITable::Restrict() returns MAPI_E_TOO_BIG (0x80040305) if the number of rows in the resulting restriction exceeds respective default maximum limits depending on the client platform and whether the client has Outlook security patch installed.
More information
Although not recommended, there is a way around this default behavior. Therecommended solution is to be more restrictive with your restrictions, asenormous restrictions are unlikely to perform well.

The default maximum row count is modifiable on the client as a profileentry. To adjust this value set the PR_PROFILE_MAX_RESTRICT entry to themaximum count desired. Please see the Edkmdb.h file (in the BackOffice SDK)for details and constants. The following code demonstrates one possible wayto set this property to 20000:

Sample Code

   HRESULT SetMaxRows()   {      // The following header files must be included      // for this code to compile correctly:      // #include <objbase.h>      // #include <mapix.h>      // #include <edk.h>      // #include <edkmdb.h>      // The following library files must be included      // for this code to compile and link correctly:      // kernel32.lib user32.lib MSVCRT.LIB mapi32.lib edkguid.lib      // edkutils.lib edkmapi.lib edkdebug.lib      HRESULT hRes = S_OK; // HRESULT error code 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.      SPropValue pProps[1]; // Pointer to PropValue PR_PROFILE_MAX_RESTRICT      // Zero out pProps.      ZeroMemory ( &pProps, sizeof ( SPropValue ) );      if ( FAILED ( hRes = MAPIInitialize ( NULL ) ) )         return hRes;      // Get a Profile admin object.      if ( FAILED ( MAPIAdminProfiles ( 0L, &pAdminProfiles ) ) )         goto CleanUp;      // Get a ServiceAdmin object.      if (FAILED(hRes = pAdminProfiles -> AdminServices("[profile name]",      // Profile name                   NULL, // Profile password if needed                   0L,   // HWND of your application. Can be 0.                   0L,   // Flags                   &pSvcAdmin  // Pointer to IServiceAdmin                   )))      goto CleanUp;      // Get the Global Profile Section by calling      // IServiceAdmin::OpenProfileSection      // Use pbGlobalProfileSectionGuid defined in Edkmdb.h as the entry ID      // to request. An IProfSect interface is returned by default.      if (FAILED(hRes = pSvcAdmin -> OpenProfileSection      ((LPMAPIUID) pbGlobalProfileSectionGuid,                       NULL,  // NULL == IProfSect interface       MAPI_MODIFY, // Access to object                       &pGlobalProfSect // Pointer to IProfSect                       ) ) )      goto CleanUp;      // Set pProps->ulProptag and Value.ul = PR_PROFILE_MAX_RESTRICT and      // 20000 respectively.      pProps->ulPropTag = PR_PROFILE_MAX_RESTRICT;      pProps->Value.ul = 20000;      // Call HrSetOneProp to get PR_PROFILE_MAX_RESTRICT.      if ( FAILED ( hRes = HrSetOneProp ( pGlobalProfSect,                                          pProps ) ) )      goto CleanUp;      CleanUp:      // Free and reset all memory allocated by any MAPI calls.      if ( NULL != pAdminProfiles )         pAdminProfiles -> Release ( );      if ( NULL != pSvcAdmin )         pSvcAdmin -> Release ( );      if ( NULL != pGlobalProfSect )         pGlobalProfSect -> Release ( );      pSvcAdmin = NULL;      pGlobalProfSect = NULL;      pAdminProfiles = NULL;      // Return the HRESULT to the calling function.      return hRes;      }				
kbDSupport kbMsg kbEDK kbMAPI100 EDKAPI EMAPI MAPIIAB kbdse
Properties

Article ID: 188295 - Last Review: 01/11/2015 01:51:19 - Revision: 5.0

  • Microsoft Office Outlook 2007
  • Microsoft Messaging Application Programming Interface
  • kbnosurvey kbarchive kbapi kbinfo kbmsg KB188295
Feedback