Microsoft KB Archive/188295

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

Article ID: 188295

Article Last Modified on 11/9/2005

-

APPLIES TO


 * Microsoft Exchange Development Kit 5.5
 * Microsoft Exchange Server 2003 Software Development Kit
 * Microsoft Messaging Application Programming Interface

-



This article was previously published under Q188295





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      // #include       // #include       // #include 

// 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; }

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

Keywords: kbinfo kbapi kbmsg KB188295

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.