Fix issue #384, patch from Milan Crha:
authorJulien Kerihuel <j.kerihuel@openchange.org>
Mon, 27 Feb 2012 13:31:57 +0000 (13:31 +0000)
committerJulien Kerihuel <j.kerihuel@openchange.org>
Mon, 27 Feb 2012 13:31:57 +0000 (13:31 +0000)
The nspi_GetMatches currently hardcodes search result limit to 5000,
which results in [1], and MAPI_E_TABLE_TOO_BIG errors. It would be nice
to provide a new argument for the search result size limit, rather than
hard code it.

doc/examples/fetch_addressbook.c
libmapi/IProfAdmin.c
libmapi/libmapi.h
libmapi/nspi.c
utils/mapitest/modules/module_nspi.c

index 370c8789864d3adebe11b307b1ccc3a3447a1521..0991e84ab30e3c6179277c78fc302cb8a6214938 100644 (file)
@@ -65,7 +65,7 @@ int main(int argc, char *argv[])
 
        /* construct an explicit table */
        MIds = talloc_zero(mem_ctx, struct SPropTagArray);
-       retval = nspi_GetMatches(nspi_ctx, mem_ctx, NULL, &Filter, &srowset, &MIds);
+       retval = nspi_GetMatches(nspi_ctx, mem_ctx, NULL, &Filter, 5000, &srowset, &MIds);
        MAPI_RETVAL_IF(retval, retval, NULL);
 
        /* fetch the contents of the explicit table */
index 08007ea7cb087c3c72fcc62705f1336beeabce7a..1f83005cdf495423fc8d408e421c06a35d60255f 100644 (file)
@@ -1632,7 +1632,7 @@ _PUBLIC_ enum MAPISTATUS ProcessNetworkProfile(struct mapi_session *session,
 
        SRowSet = talloc_zero(mem_ctx, struct SRowSet);
        MIds = talloc_zero(mem_ctx, struct PropertyTagArray_r);
-       retval = nspi_GetMatches(nspi, mem_ctx, SPropTagArray, &Filter, &SRowSet, &MIds);
+       retval = nspi_GetMatches(nspi, mem_ctx, SPropTagArray, &Filter, 5000, &SRowSet, &MIds);
        MAPIFreeBuffer(SPropTagArray);
        MAPIFreeBuffer(lpProp);
        if (retval != MAPI_E_SUCCESS) {
index 27468e697e8092c6d3d0687e575107985362115f..ab32a6261072585347d43f9cbfd5849d5c36f22d 100644 (file)
@@ -96,7 +96,7 @@ enum MAPISTATUS               nspi_unbind(struct nspi_context *);
 enum MAPISTATUS                nspi_UpdateStat(struct nspi_context *, TALLOC_CTX *, uint32_t *);
 enum MAPISTATUS                nspi_QueryRows(struct nspi_context *, TALLOC_CTX *, struct SPropTagArray *, struct PropertyTagArray_r *MIds, uint32_t, struct SRowSet **);
 enum MAPISTATUS                nspi_SeekEntries(struct nspi_context *, TALLOC_CTX *, enum TableSortOrders, struct SPropValue *, struct SPropTagArray *, struct PropertyTagArray_r *pMIds, struct SRowSet **);
-enum MAPISTATUS                nspi_GetMatches(struct nspi_context *, TALLOC_CTX *, struct SPropTagArray *, struct Restriction_r *, struct SRowSet **, struct PropertyTagArray_r **ppOutMIds);
+enum MAPISTATUS                nspi_GetMatches(struct nspi_context *, TALLOC_CTX *, struct SPropTagArray *, struct Restriction_r *, uint32_t ulRequested, struct SRowSet **, struct PropertyTagArray_r **ppOutMIds);
 enum MAPISTATUS                nspi_ResortRestriction(struct nspi_context *, TALLOC_CTX *, enum TableSortOrders, struct PropertyTagArray_r *pInMIds, struct PropertyTagArray_r **ppMIds);
 enum MAPISTATUS                nspi_DNToMId(struct nspi_context *, TALLOC_CTX *, struct StringsArray_r *, struct PropertyTagArray_r **ppMIds);
 enum MAPISTATUS                nspi_GetPropList(struct nspi_context *, TALLOC_CTX *, bool, uint32_t, struct SPropTagArray **);
index d4743191c87974e5751c3a094a7c4d4be1daa1d3..e076480181978944f4532cab5ecca9707c2bb8cb 100644 (file)
@@ -390,17 +390,22 @@ _PUBLIC_ enum MAPISTATUS nspi_SeekEntries(struct nspi_context *nspi_ctx,
    \param mem_ctx pointer to the memory context
    \param pPropTags pointer to an array of property tags of columns
    \param Filter pointer to the Restriction to apply to the table
+   \param ulRequested The upper limit for returned rows
    \param ppRows pointer to pointer to a SRowSet structure holding the
    rows returned by the server
    \param ppOutMIds pointer to pointer to a list of MId that comprise
    a restricted address book container
 
-   \return MAPI_E_SUCCESS on success, otherwise MAPI error.
+   \return MAPI_E_SUCCESS on success, otherwise MAPI error. If the resulting
+   table rows count will be greater than ulRequested, then an error
+   MAPI_E_TABLE_TOO_BIG is returned. Note, this error can be also returned
+   when server limits for table size are exceeded.
  */
 _PUBLIC_ enum MAPISTATUS nspi_GetMatches(struct nspi_context *nspi_ctx, 
                                         TALLOC_CTX *mem_ctx,
                                         struct SPropTagArray *pPropTags,
                                         struct Restriction_r *Filter,
+                                        uint32_t ulRequested,
                                         struct SRowSet **ppRows,
                                         struct PropertyTagArray_r **ppOutMIds)
 {
@@ -429,7 +434,7 @@ _PUBLIC_ enum MAPISTATUS nspi_GetMatches(struct nspi_context *nspi_ctx,
        r.in.Reserved2 = 0;
        r.in.Filter = Filter;
        r.in.lpPropName = NULL;
-       r.in.ulRequested = 5000;
+       r.in.ulRequested = ulRequested;
        r.in.pPropTags = pPropTags;
 
        pStat = talloc(mem_ctx, struct STAT);
index ed07be4321ee4f6101c7dafae57be7bccd156465..30e5838f793e6caf094fe5fff622bdb1d4182fb5 100644 (file)
@@ -106,7 +106,7 @@ _PUBLIC_ bool mapitest_nspi_QueryRows(struct mapitest *mt)
 
        SRowSet = talloc_zero(mem_ctx, struct SRowSet);
        MIds = talloc_zero(mem_ctx, struct PropertyTagArray_r);
-       retval = nspi_GetMatches(nspi_ctx, mem_ctx, SPropTagArray, &Filter, &SRowSet, &MIds);
+       retval = nspi_GetMatches(nspi_ctx, mem_ctx, SPropTagArray, &Filter, 5000, &SRowSet, &MIds);
        MAPIFreeBuffer(lpProp);
        MAPIFreeBuffer(SRowSet);
        MAPIFreeBuffer(SPropTagArray);
@@ -233,7 +233,7 @@ _PUBLIC_ bool mapitest_nspi_GetMatches(struct mapitest *mt)
 
        SRowSet = talloc_zero(mem_ctx, struct SRowSet);
        MIds = talloc_zero(mem_ctx, struct PropertyTagArray_r);
-       retval = nspi_GetMatches(nspi_ctx, mem_ctx, SPropTagArray, &Filter, &SRowSet, &MIds);
+       retval = nspi_GetMatches(nspi_ctx, mem_ctx, SPropTagArray, &Filter, 5000, &SRowSet, &MIds);
        MAPIFreeBuffer(lpProp);
        MAPIFreeBuffer(SRowSet);
        MAPIFreeBuffer(SPropTagArray);
@@ -299,7 +299,7 @@ _PUBLIC_ bool mapitest_nspi_ResortRestriction(struct mapitest *mt)
 
        SRowSet = talloc_zero(mem_ctx, struct SRowSet);
        MIds = talloc_zero(mem_ctx, struct PropertyTagArray_r);
-       retval = nspi_GetMatches(nspi_ctx, mem_ctx, SPropTagArray, &Filter, &SRowSet, &MIds);
+       retval = nspi_GetMatches(nspi_ctx, mem_ctx, SPropTagArray, &Filter, 5000, &SRowSet, &MIds);
        MAPIFreeBuffer(lpProp);
        MAPIFreeBuffer(SPropTagArray);
        MAPIFreeBuffer(SRowSet);
@@ -400,7 +400,7 @@ _PUBLIC_ bool mapitest_nspi_GetPropList(struct mapitest *mt)
 
        SRowSet = talloc_zero(mem_ctx, struct SRowSet);
        MIds = talloc_zero(mem_ctx, struct PropertyTagArray_r);
-       retval = nspi_GetMatches(nspi_ctx, mem_ctx, SPropTagArray, &Filter, &SRowSet, &MIds);
+       retval = nspi_GetMatches(nspi_ctx, mem_ctx, SPropTagArray, &Filter, 5000, &SRowSet, &MIds);
        MAPIFreeBuffer(SPropTagArray);
        MAPIFreeBuffer(lpProp);
        MAPIFreeBuffer(SRowSet);
@@ -525,7 +525,7 @@ _PUBLIC_ bool mapitest_nspi_CompareMIds(struct mapitest *mt)
 
        SRowSet = talloc_zero(mem_ctx, struct SRowSet);
        MIds = talloc_zero(mem_ctx, struct PropertyTagArray_r);
-       retval = nspi_GetMatches(nspi_ctx, mem_ctx, SPropTagArray, &Filter, &SRowSet, &MIds);
+       retval = nspi_GetMatches(nspi_ctx, mem_ctx, SPropTagArray, &Filter, 5000, &SRowSet, &MIds);
        MAPIFreeBuffer(lpProp);
        MAPIFreeBuffer(SPropTagArray);
        MAPIFreeBuffer(SRowSet);
@@ -602,7 +602,7 @@ _PUBLIC_ bool mapitest_nspi_ModProps(struct mapitest *mt)
 
        SRowSet = talloc_zero(mem_ctx, struct SRowSet);
        MIds = talloc_zero(mem_ctx, struct PropertyTagArray_r);
-       retval = nspi_GetMatches(nspi_ctx, mem_ctx, SPropTagArray, &Filter, &SRowSet, &MIds);
+       retval = nspi_GetMatches(nspi_ctx, mem_ctx, SPropTagArray, &Filter, 5000, &SRowSet, &MIds);
        MAPIFreeBuffer(lpProp);
        MAPIFreeBuffer(SRowSet);
        MAPIFreeBuffer(SPropTagArray);