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

Article translations Article translations
Article ID: 188295 - View products that this article applies to.
This article has been archived. It is offered "as is" and will no longer be updated.
Expand all | Collapse all

On This Page

Summary

The Microsoft Exchange Server Address Book has always limited the size of restrictions. 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. The recommended solution is to be more restrictive with your restrictions, as enormous restrictions are unlikely to perform well.

The default maximum row count is modifiable on the client as a profile entry. To adjust this value set the PR_PROFILE_MAX_RESTRICT entry to the maximum count desired. Please see the Edkmdb.h file (in the BackOffice SDK) for details and constants. The following code demonstrates one possible way to 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;
      }
				

Properties

Article ID: 188295 - Last Review: December 23, 2014 - Revision: 5.0
Applies to
  • Microsoft Office Outlook 2007
  • Microsoft Messaging Application Programming Interface
Keywords: 
kbnosurvey kbarchive kbapi kbinfo kbmsg KB188295

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com