INFO: IMAPITable::Restrict 16000 Row Limitation in Exchange AB

ID: Q188295

The information in this article applies to:

SUMMARY

The Microsoft Exchange Server Address Book has always limited the size of restrictions. The default maximum row restriction is 16000 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 16000 or 4000, depending on the client platform.

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 -> penProfileSection
      ((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;
      }

Additional query words: kbDSupport kbMsg kbEDK kbMAPI100 EDKAPI EMAPI MAPIIAB kbdse

Keywords          : kbAPI kbEDK kbMsg kbMAPI100 MAPIIAB 
Version           : WINDOWS:1.0,5.0,5.5
Platform          : WINDOWS
Issue type        : kbinfo

Last Reviewed: July 2, 1998