/** \details Test dump using mapidump_pabentry This function: -# Tests the mapidump_PAB_entry() function \param mt pointer to the top-level mapitest structure \return true on success, otherwise false \note This currently doesn't check the results are sane, so manual inspection is required */ _PUBLIC_ bool mapitest_mapidump_pabentry(struct mapitest *mt) { struct PropertyRow_r pabentry; struct PropertyValue_r value; pabentry.cValues = 0; pabentry.lpProps = talloc_zero(mt->mem_ctx, struct PropertyValue_r); value.ulPropTag = PR_ADDRTYPE_UNICODE; value.value.lpszA = "dummy addrtype"; PropertyRow_addprop(&(pabentry), value); value.ulPropTag = PR_DISPLAY_NAME_UNICODE; value.value.lpszA = "dummy display name"; PropertyRow_addprop(&(pabentry), value); value.ulPropTag = PR_EMAIL_ADDRESS_UNICODE; value.value.lpszA = "*****@*****.**"; PropertyRow_addprop(&(pabentry), value); value.ulPropTag = PR_ACCOUNT_UNICODE; value.value.lpszA = "dummy account"; PropertyRow_addprop(&(pabentry), value); mapidump_PAB_entry(&pabentry); return true; }
/** \details Test the NspiModProps RPC operation (0xb) \param mt pointer on the top-level mapitest structure \return true on success, otherwise false */ _PUBLIC_ bool mapitest_nspi_ModProps(struct mapitest *mt) { TALLOC_CTX *mem_ctx; enum MAPISTATUS retval; struct nspi_context *nspi_ctx; struct PropertyRow_r *pRow; struct SPropTagArray *pPropTags; struct PropertyValue_r modProp; struct PropertyTagArray_r *MIds; struct PropertyRowSet_r *RowSet; struct SPropTagArray *SPropTagArray; struct PropertyValue_r *lpProp; struct Restriction_r Filter; const char *original_office_location; bool ret = true; mem_ctx = talloc_named(NULL, 0, "mapitest_nspi_ModProps"); nspi_ctx = (struct nspi_context *) mt->session->nspi->ctx; /* Build the array of columns we want to retrieve */ SPropTagArray = set_SPropTagArray(mem_ctx, 0x2, PR_DISPLAY_NAME, PR_DISPLAY_TYPE); /* Build the restriction we want for NspiGetMatches */ lpProp = talloc_zero(mem_ctx, struct PropertyValue_r); lpProp->ulPropTag = PR_ACCOUNT; lpProp->dwAlignPad = 0; lpProp->value.lpszA = mt->mapi_ctx->session->profile->username; Filter.rt = RES_PROPERTY; Filter.res.resProperty.relop = RES_PROPERTY; Filter.res.resProperty.ulPropTag = PR_ACCOUNT; Filter.res.resProperty.lpProp = lpProp; RowSet = talloc_zero(mem_ctx, struct PropertyRowSet_r); MIds = talloc_zero(mem_ctx, struct PropertyTagArray_r); retval = nspi_GetMatches(nspi_ctx, mem_ctx, SPropTagArray, &Filter, 5000, &RowSet, &MIds); MAPIFreeBuffer(lpProp); MAPIFreeBuffer(RowSet); MAPIFreeBuffer(SPropTagArray); mapitest_print_retval_clean(mt, "nspi_GetMatches", retval); if (retval != MAPI_E_SUCCESS) { MAPIFreeBuffer(MIds); talloc_free(mem_ctx); return false; } /* Query the rows */ RowSet = talloc_zero(mem_ctx, struct PropertyRowSet_r); retval = nspi_QueryRows(nspi_ctx, mem_ctx, NULL, MIds, 1, &RowSet); mapitest_print_retval_clean(mt, "nspi_QueryRows", retval); if (retval != MAPI_E_SUCCESS) { MAPIFreeBuffer(MIds); MAPIFreeBuffer(RowSet); talloc_free(mem_ctx); return false; } if (RowSet->cRows != 1) { mapitest_print(mem_ctx, "unexpected number of rows: %i\n", RowSet->cRows); MAPIFreeBuffer(MIds); MAPIFreeBuffer(RowSet); talloc_free(mem_ctx); return false; } original_office_location = (const char *)find_PropertyValue_data(&(RowSet->aRow[0]), PR_OFFICE_LOCATION); mapitest_print(mt, "original PR_OFFICE_LOCATION value: %s\n", original_office_location); /* Build the SRow and SPropTagArray for NspiModProps */ pRow = talloc_zero(mem_ctx, struct PropertyRow_r); modProp.ulPropTag = PR_OFFICE_LOCATION; modProp.value.lpszA = "MT office location"; PropertyRow_addprop(pRow, modProp); pPropTags = set_SPropTagArray(mem_ctx, 0x1, PR_OFFICE_LOCATION); retval = nspi_ModProps(nspi_ctx, mem_ctx, MIds->aulPropTag[0], pPropTags, pRow); mapitest_print_retval_clean(mt, "nspi_ModProps", retval); MAPIFreeBuffer(pRow); if (retval != MAPI_E_SUCCESS) { MAPIFreeBuffer(MIds); MAPIFreeBuffer(pPropTags); talloc_free(mem_ctx); return false; } /* Check that the property was set correctly */ RowSet = talloc_zero(mem_ctx, struct PropertyRowSet_r); retval = nspi_QueryRows(nspi_ctx, mem_ctx, NULL, MIds, 1, &RowSet); mapitest_print_retval_clean(mt, "nspi_QueryRows", retval); if (retval != MAPI_E_SUCCESS) { MAPIFreeBuffer(MIds); MAPIFreeBuffer(RowSet); talloc_free(mem_ctx); return false; } if (RowSet->cRows != 1) { mapitest_print(mem_ctx, "unexpected number of rows: %i\n", RowSet->cRows); MAPIFreeBuffer(MIds); MAPIFreeBuffer(RowSet); talloc_free(mem_ctx); return false; } if (strcmp((const char *)find_PropertyValue_data(&(RowSet->aRow[0]), PR_OFFICE_LOCATION), "MT office location") != 0) { mapitest_print(mt, "PR_OFFICE_LOCATION string value mismatch: %s", (const char *)find_PropertyValue_data(&(RowSet->aRow[0]), PR_OFFICE_LOCATION)); ret = false; } else { mapitest_print(mt, "correctly set PR_OFFICE_LOCATION\n"); } /* try to reset the office location back to the original value */ pRow = talloc_zero(mem_ctx, struct PropertyRow_r); modProp.ulPropTag = PR_OFFICE_LOCATION; modProp.value.lpszA = original_office_location; PropertyRow_addprop(pRow, modProp); retval = nspi_ModProps(nspi_ctx, mem_ctx, MIds->aulPropTag[0], pPropTags, pRow); mapitest_print_retval_clean(mt, "nspi_ModProps (reset original value)", retval); if (retval != MAPI_E_SUCCESS) { ret = false; } MAPIFreeBuffer(MIds); MAPIFreeBuffer(pPropTags); MAPIFreeBuffer(pRow); talloc_free(mem_ctx); return ret; }