2 Stand-alone MAPI testsuite
4 OpenChange Project - NSPI tests
6 Copyright (C) Julien Kerihuel 2008
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "utils/mapitest/mapitest.h"
23 #include "utils/mapitest/proto.h"
33 \details Test the NspiUpdateStat RPC operation (0x02)
35 \param mt pointer on the top-level mapitest structure
37 \return true on success, otherwise false
39 _PUBLIC_ bool mapitest_nspi_UpdateStat(struct mapitest *mt)
42 enum MAPISTATUS retval;
43 struct nspi_context *nspi_ctx;
45 struct SRowSet *SRowSet;
47 mem_ctx = talloc_named(NULL, 0, "mapitest_nspi_UpdateStat");
48 nspi_ctx = (struct nspi_context *) mt->session->nspi->ctx;
50 SRowSet = talloc_zero(mem_ctx, struct SRowSet);
51 retval = nspi_GetSpecialTable(nspi_ctx, mem_ctx, 0x2, &SRowSet);
52 MAPIFreeBuffer(SRowSet);
53 if (retval != MAPI_E_SUCCESS) {
58 retval = nspi_UpdateStat(nspi_ctx, mem_ctx, &plDelta);
59 mapitest_print_retval(mt, "NspiUpdateStat");
60 if (retval != MAPI_E_SUCCESS) {
64 mapitest_print(mt, "* %-35s: %d\n", "plDelta", plDelta);
72 \details Test the NspiQueryRows RPC operation (0x3)
74 \param mt pointer on the top-level mapitest structure
76 \return true on success, otherwise false
78 _PUBLIC_ bool mapitest_nspi_QueryRows(struct mapitest *mt)
81 enum MAPISTATUS retval;
82 struct nspi_context *nspi_ctx;
83 struct PropertyTagArray_r *MIds;
84 struct SRowSet *SRowSet;
85 struct SPropTagArray *SPropTagArray;
86 struct SPropValue *lpProp;
87 struct Restriction_r Filter;
89 mem_ctx = talloc_named(NULL, 0, "mapitest_nspi_QueryRows");
90 nspi_ctx = (struct nspi_context *) mt->session->nspi->ctx;
92 /* Build the array of columns we want to retrieve */
93 SPropTagArray = set_SPropTagArray(mem_ctx, 0x2, PR_DISPLAY_NAME,
96 /* Build the restriction we want for NspiGetMatches */
97 lpProp = talloc_zero(mem_ctx, struct SPropValue);
98 lpProp->ulPropTag = PR_ACCOUNT;
99 lpProp->dwAlignPad = 0;
100 lpProp->value.lpszA = mt->mapi_ctx->session->profile->username;
102 Filter.rt = RES_PROPERTY;
103 Filter.res.resProperty.relop = RES_PROPERTY;
104 Filter.res.resProperty.ulPropTag = PR_ACCOUNT;
105 Filter.res.resProperty.lpProp = lpProp;
107 SRowSet = talloc_zero(mem_ctx, struct SRowSet);
108 MIds = talloc_zero(mem_ctx, struct PropertyTagArray_r);
109 retval = nspi_GetMatches(nspi_ctx, mem_ctx, SPropTagArray, &Filter, 5000, &SRowSet, &MIds);
110 MAPIFreeBuffer(lpProp);
111 MAPIFreeBuffer(SRowSet);
112 MAPIFreeBuffer(SPropTagArray);
113 mapitest_print_retval_clean(mt, "NspiGetMatches", retval);
114 if (retval != MAPI_E_SUCCESS) {
115 MAPIFreeBuffer(MIds);
116 talloc_free(mem_ctx);
121 SRowSet = talloc_zero(mem_ctx, struct SRowSet);
122 retval = nspi_QueryRows(nspi_ctx, mem_ctx, NULL, MIds, 1, &SRowSet);
123 MAPIFreeBuffer(SRowSet);
124 mapitest_print_retval_clean(mt, "NspiQueryRows", retval);
125 if (retval != MAPI_E_SUCCESS) {
126 MAPIFreeBuffer(MIds);
127 talloc_free(mem_ctx);
131 talloc_free(mem_ctx);
138 \details Test the NspiSeekEntries RPC operation (0x04)
140 \param mt pointer on the top-level mapitest structure
142 \return true on success, otherwise false
144 _PUBLIC_ bool mapitest_nspi_SeekEntries(struct mapitest *mt)
147 enum MAPISTATUS retval;
148 struct nspi_context *nspi_ctx;
149 struct SPropValue pTarget;
150 struct SPropTagArray *pPropTags;
151 struct SRowSet *SRowSet;
152 struct emsmdb_context *emsmdb;
155 mem_ctx = talloc_named(NULL, 0, "mapitest_nspi_SeekEntries");
156 nspi_ctx = (struct nspi_context *) mt->session->nspi->ctx;
158 emsmdb = (struct emsmdb_context *) mt->session->emsmdb->ctx;
159 SRowSet = talloc_zero(mem_ctx, struct SRowSet);
161 pTarget.ulPropTag = PR_DISPLAY_NAME;
162 pTarget.dwAlignPad = 0x0;
163 pTarget.value.lpszA = emsmdb->info.szDisplayName;
165 pPropTags = set_SPropTagArray(mem_ctx, 0x1, PR_ACCOUNT);
166 retval = nspi_SeekEntries(nspi_ctx, mem_ctx, SortTypeDisplayName, &pTarget, pPropTags, NULL, &SRowSet);
167 if (retval != MAPI_E_SUCCESS) {
171 mapitest_print_retval_clean(mt, "NspiSeekEntries", retval);
172 MAPIFreeBuffer(SRowSet);
173 MAPIFreeBuffer(pPropTags);
175 SRowSet = talloc_zero(mem_ctx, struct SRowSet);
177 pTarget.ulPropTag = PR_DISPLAY_NAME_UNICODE;
178 pTarget.dwAlignPad = 0x0;
179 pTarget.value.lpszA = emsmdb->info.szDisplayName;
181 pPropTags = set_SPropTagArray(mem_ctx, 0x1, PR_ACCOUNT);
182 retval = nspi_SeekEntries(nspi_ctx, mem_ctx, SortTypeDisplayName, &pTarget, pPropTags, NULL, &SRowSet);
183 if (retval != MAPI_E_SUCCESS) {
187 mapitest_print_retval_clean(mt, "NspiSeekEntries", retval);
188 MAPIFreeBuffer(SRowSet);
189 MAPIFreeBuffer(pPropTags);
191 talloc_free(mem_ctx);
198 \details Test the NspiGetMatches RPC operation (0x5)
200 \param mt pointer on the top-level mapitest structure
202 \return true on success, otherwise false
204 _PUBLIC_ bool mapitest_nspi_GetMatches(struct mapitest *mt)
207 enum MAPISTATUS retval;
208 struct nspi_context *nspi_ctx;
209 struct PropertyTagArray_r *MIds;
210 struct SRowSet *SRowSet;
211 struct SPropTagArray *SPropTagArray;
212 struct SPropValue *lpProp;
213 struct Restriction_r Filter;
216 mem_ctx = talloc_named(NULL, 0, "mapitest_nspi_GetMatches");
217 nspi_ctx = (struct nspi_context *) mt->session->nspi->ctx;
219 /* Build the array of columns we want to retrieve */
220 SPropTagArray = set_SPropTagArray(mem_ctx, 0x2, PR_DISPLAY_NAME,
223 /* Build the restriction we want for NspiGetMatches */
224 lpProp = talloc_zero(mem_ctx, struct SPropValue);
225 lpProp->ulPropTag = PR_ACCOUNT;
226 lpProp->dwAlignPad = 0;
227 lpProp->value.lpszA = mt->mapi_ctx->session->profile->username;
229 Filter.rt = RES_PROPERTY;
230 Filter.res.resProperty.relop = RES_PROPERTY;
231 Filter.res.resProperty.ulPropTag = PR_ACCOUNT;
232 Filter.res.resProperty.lpProp = lpProp;
234 SRowSet = talloc_zero(mem_ctx, struct SRowSet);
235 MIds = talloc_zero(mem_ctx, struct PropertyTagArray_r);
236 retval = nspi_GetMatches(nspi_ctx, mem_ctx, SPropTagArray, &Filter, 5000, &SRowSet, &MIds);
237 MAPIFreeBuffer(lpProp);
238 MAPIFreeBuffer(SRowSet);
239 MAPIFreeBuffer(SPropTagArray);
240 MAPIFreeBuffer(MIds);
241 mapitest_print_retval_clean(mt, "NspiGetMatches", retval);
242 if (retval != MAPI_E_SUCCESS) {
246 talloc_free(mem_ctx);
252 \details Test the NspiResortRestriction RPC operation (0x6)
254 \param mt pointer on the top-level mapitest structure
256 \return true on success, otherwise false
258 _PUBLIC_ bool mapitest_nspi_ResortRestriction(struct mapitest *mt)
261 enum MAPISTATUS retval;
262 struct nspi_context *nspi_ctx;
263 struct Restriction_r Filter;
264 struct SRowSet *SRowSet = NULL;
265 struct SPropTagArray *SPropTagArray = NULL;
266 struct SPropValue *lpProp = NULL;
267 struct PropertyTagArray_r *MIds = NULL;
268 struct PropertyTagArray_r *ppMIds = NULL;
271 mem_ctx = talloc_named(NULL, 0, "mapitest_nspi_ResortRestriction");
272 nspi_ctx = (struct nspi_context *) mt->session->nspi->ctx;
274 /* Build the array of columns we want to retrieve */
275 SPropTagArray = set_SPropTagArray(mem_ctx, 0xb,
277 PR_OFFICE_TELEPHONE_NUMBER,
289 /* Build the restriction we want for NspiGetMatches */
290 lpProp = talloc_zero(mem_ctx, struct SPropValue);
291 lpProp->ulPropTag = PR_OBJECT_TYPE;
292 lpProp->dwAlignPad = 0;
295 Filter.rt = RES_PROPERTY;
296 Filter.res.resProperty.relop = RES_PROPERTY;
297 Filter.res.resProperty.ulPropTag = PR_OBJECT_TYPE;
298 Filter.res.resProperty.lpProp = lpProp;
300 SRowSet = talloc_zero(mem_ctx, struct SRowSet);
301 MIds = talloc_zero(mem_ctx, struct PropertyTagArray_r);
302 retval = nspi_GetMatches(nspi_ctx, mem_ctx, SPropTagArray, &Filter, 5000, &SRowSet, &MIds);
303 MAPIFreeBuffer(lpProp);
304 MAPIFreeBuffer(SPropTagArray);
305 MAPIFreeBuffer(SRowSet);
306 mapitest_print_retval_clean(mt, "NspiGetMatches", retval);
307 if (retval != MAPI_E_SUCCESS) {
308 MAPIFreeBuffer(MIds);
309 talloc_free(mem_ctx);
313 ppMIds = talloc_zero(mem_ctx, struct PropertyTagArray_r);
314 retval = nspi_ResortRestriction(nspi_ctx, mem_ctx, SortTypeDisplayName, MIds, &ppMIds);
315 mapitest_print_retval_clean(mt, "NspiResortRestriction", retval);
316 if (retval != MAPI_E_SUCCESS) {
320 MAPIFreeBuffer(MIds);
321 MAPIFreeBuffer(ppMIds);
322 talloc_free(mem_ctx);
329 \details Test the NspiDNToMId RPC operation (0x7)
331 \param mt pointer on the top-level mapitest structure
333 \return true on success, otherwise false
335 _PUBLIC_ bool mapitest_nspi_DNToMId(struct mapitest *mt)
338 enum MAPISTATUS retval;
339 struct nspi_context *nspi_ctx;
340 struct StringsArray_r pNames;
341 struct PropertyTagArray_r *MId;
343 mem_ctx = talloc_named(NULL, 0, "mapitest_nspi_DNToMId");
344 nspi_ctx = (struct nspi_context *) mt->session->nspi->ctx;
347 pNames.Strings = (const char **) talloc_array(mem_ctx, char **, 1);
348 pNames.Strings[0] = mt->mapi_ctx->session->profile->homemdb;
350 MId = talloc_zero(mem_ctx, struct PropertyTagArray_r);
352 retval = nspi_DNToMId(nspi_ctx, mem_ctx, &pNames, &MId);
353 MAPIFreeBuffer((char **)pNames.Strings);
355 talloc_free(mem_ctx);
357 mapitest_print_retval_clean(mt, "NspiDNToMId", retval);
359 if (retval == MAPI_E_SUCCESS) {
368 \details Test the NspiGetPropList RPC operation (0x08)
370 \param mt pointer on the top-level mapitest structure
372 \return true on success, otherwise false
374 _PUBLIC_ bool mapitest_nspi_GetPropList(struct mapitest *mt)
377 enum MAPISTATUS retval;
378 struct nspi_context *nspi_ctx;
379 struct SPropTagArray *pPropTags = 0;
380 struct PropertyTagArray_r *MIds;
381 struct SPropValue *lpProp;
382 struct Restriction_r Filter;
383 struct SPropTagArray *SPropTagArray;
384 struct SRowSet *SRowSet;
386 mem_ctx = talloc_named(NULL, 0, "mapitest_nspi_GetPropList");
387 nspi_ctx = (struct nspi_context *) mt->session->nspi->ctx;
389 /* Step 1. Query for current profile username */
390 SPropTagArray = set_SPropTagArray(mem_ctx, 0x1, PR_DISPLAY_NAME);
391 lpProp = talloc_zero(mem_ctx, struct SPropValue);
392 lpProp->ulPropTag = PR_ANR_UNICODE;
393 lpProp->dwAlignPad = 0;
394 lpProp->value.lpszW = mt->mapi_ctx->session->profile->username;
396 Filter.rt = RES_PROPERTY;
397 Filter.res.resProperty.relop = RES_PROPERTY;
398 Filter.res.resProperty.ulPropTag = PR_ANR_UNICODE;
399 Filter.res.resProperty.lpProp = lpProp;
401 SRowSet = talloc_zero(mem_ctx, struct SRowSet);
402 MIds = talloc_zero(mem_ctx, struct PropertyTagArray_r);
403 retval = nspi_GetMatches(nspi_ctx, mem_ctx, SPropTagArray, &Filter, 5000, &SRowSet, &MIds);
404 MAPIFreeBuffer(SPropTagArray);
405 MAPIFreeBuffer(lpProp);
406 MAPIFreeBuffer(SRowSet);
407 if (retval != MAPI_E_SUCCESS) {
408 MAPIFreeBuffer(MIds);
409 talloc_free(mem_ctx);
414 /* Step 2. Call NspiGetPropList using the MId returned by NspiGetMatches */
415 pPropTags = talloc_zero(mt->mem_ctx, struct SPropTagArray);
416 retval = nspi_GetPropList(nspi_ctx, mem_ctx, 0, MIds->aulPropTag[0], &pPropTags);
417 MAPIFreeBuffer(MIds);
418 mapitest_print_retval(mt, "NspiGetPropList");
420 if (retval != MAPI_E_SUCCESS) {
421 MAPIFreeBuffer(pPropTags);
422 talloc_free(mem_ctx);
427 mapitest_print(mt, "* %-35s: %d\n", "Properties number", pPropTags->cValues);
428 MAPIFreeBuffer(pPropTags);
430 talloc_free(mem_ctx);
437 \details Test the NspiGetProps RPC operation (0x09)
439 \param mt pointer to the top-level mapitest structure
441 \return true on success, otherwise false
443 _PUBLIC_ bool mapitest_nspi_GetProps(struct mapitest *mt)
446 enum MAPISTATUS retval;
447 struct nspi_context *nspi_ctx;
448 struct StringsArray_r pNames;
449 struct PropertyTagArray_r *MId;
450 struct SPropTagArray *SPropTagArray;
451 struct SRowSet *SRowSet;
453 mem_ctx = talloc_named(NULL, 0, "mapitest_nspi_GetProps");
454 nspi_ctx = (struct nspi_context *) mt->session->nspi->ctx;
457 pNames.Strings = (const char **) talloc_array(mem_ctx, char **, 1);
458 pNames.Strings[0] = mt->mapi_ctx->session->profile->homemdb;
460 MId = talloc_zero(mem_ctx, struct PropertyTagArray_r);
462 retval = nspi_DNToMId(nspi_ctx, mem_ctx, &pNames, &MId);
463 MAPIFreeBuffer((char **)pNames.Strings);
464 mapitest_print_retval(mt, "NspiDNToMId");
466 if (retval != MAPI_E_SUCCESS) {
468 talloc_free(mem_ctx);
472 SRowSet = talloc_zero(mem_ctx, struct SRowSet);
473 SPropTagArray = set_SPropTagArray(mem_ctx, 0x1, PR_EMS_AB_NETWORK_ADDRESS);
474 retval = nspi_GetProps(nspi_ctx, mem_ctx, SPropTagArray, MId, &SRowSet);
475 mapitest_print_retval_clean(mt, "NspiGetProps", retval);
476 MAPIFreeBuffer(SPropTagArray);
478 MAPIFreeBuffer(SRowSet);
480 talloc_free(mem_ctx);
482 if (retval == MAPI_E_SUCCESS) {
491 \details Test the NspiCompareMIds RPC operation (0x0a)
493 \param mt pointer to the top-level mapitest structure
495 \return true on success, otherwise false
497 _PUBLIC_ bool mapitest_nspi_CompareMIds(struct mapitest *mt)
500 enum MAPISTATUS retval;
501 struct nspi_context *nspi_ctx;
503 struct PropertyTagArray_r *MIds;
504 struct SRowSet *SRowSet;
505 struct SPropTagArray *SPropTagArray;
506 struct SPropValue *lpProp;
507 struct Restriction_r Filter;
509 mem_ctx = talloc_named(NULL, 0, "mapitest_nspi_CompareMIds");
510 nspi_ctx = (struct nspi_context *) mt->session->nspi->ctx;
512 /* Build the array of columns we want to retrieve */
513 SPropTagArray = set_SPropTagArray(mem_ctx, 0x1, PR_DISPLAY_NAME);
515 /* Build the restriction we want for NspiGetMatches */
516 lpProp = talloc_zero(mem_ctx, struct SPropValue);
517 lpProp->ulPropTag = PR_OBJECT_TYPE;
518 lpProp->dwAlignPad = 0;
521 Filter.rt = RES_PROPERTY;
522 Filter.res.resProperty.relop = RES_PROPERTY;
523 Filter.res.resProperty.ulPropTag = PR_OBJECT_TYPE;
524 Filter.res.resProperty.lpProp = lpProp;
526 SRowSet = talloc_zero(mem_ctx, struct SRowSet);
527 MIds = talloc_zero(mem_ctx, struct PropertyTagArray_r);
528 retval = nspi_GetMatches(nspi_ctx, mem_ctx, SPropTagArray, &Filter, 5000, &SRowSet, &MIds);
529 MAPIFreeBuffer(lpProp);
530 MAPIFreeBuffer(SPropTagArray);
531 MAPIFreeBuffer(SRowSet);
532 mapitest_print_retval_clean(mt, "NspiGetMatches", retval);
533 if (retval != MAPI_E_SUCCESS) {
534 MAPIFreeBuffer(MIds);
535 talloc_free(mem_ctx);
539 /* Ensure we have at least two result to compare */
540 if (MIds->cValues < 2) {
541 mapitest_print(mt, "* Only one result found, can't compare\n");
542 MAPIFreeBuffer(MIds);
543 talloc_free(mem_ctx);
547 retval = nspi_CompareMIds(nspi_ctx, mem_ctx, MIds->aulPropTag[0], MIds->aulPropTag[1], &plResult);
548 mapitest_print_retval_clean(mt, "NspiCompareMIds", retval);
549 MAPIFreeBuffer(MIds);
550 if (retval != MAPI_E_SUCCESS) {
551 talloc_free(mem_ctx);
555 mapitest_print(mt, "* %-35s: %d\n", "value of the comparison", plResult);
556 talloc_free(mem_ctx);
563 \details Test the NspiModProps RPC operation (0xb)
565 \param mt pointer on the top-level mapitest structure
567 \return true on success, otherwise false
569 _PUBLIC_ bool mapitest_nspi_ModProps(struct mapitest *mt)
572 enum MAPISTATUS retval;
573 struct nspi_context *nspi_ctx;
575 struct SPropTagArray *pPropTags;
576 struct SPropValue modProp;
577 struct PropertyTagArray_r *MIds;
578 struct SRowSet *SRowSet;
579 struct SPropTagArray *SPropTagArray;
580 struct SPropValue *lpProp;
581 struct Restriction_r Filter;
582 const char *original_office_location;
585 mem_ctx = talloc_named(NULL, 0, "mapitest_nspi_ModProps");
586 nspi_ctx = (struct nspi_context *) mt->session->nspi->ctx;
588 /* Build the array of columns we want to retrieve */
589 SPropTagArray = set_SPropTagArray(mem_ctx, 0x2, PR_DISPLAY_NAME,
592 /* Build the restriction we want for NspiGetMatches */
593 lpProp = talloc_zero(mem_ctx, struct SPropValue);
594 lpProp->ulPropTag = PR_ACCOUNT;
595 lpProp->dwAlignPad = 0;
596 lpProp->value.lpszA = mt->mapi_ctx->session->profile->username;
598 Filter.rt = RES_PROPERTY;
599 Filter.res.resProperty.relop = RES_PROPERTY;
600 Filter.res.resProperty.ulPropTag = PR_ACCOUNT;
601 Filter.res.resProperty.lpProp = lpProp;
603 SRowSet = talloc_zero(mem_ctx, struct SRowSet);
604 MIds = talloc_zero(mem_ctx, struct PropertyTagArray_r);
605 retval = nspi_GetMatches(nspi_ctx, mem_ctx, SPropTagArray, &Filter, 5000, &SRowSet, &MIds);
606 MAPIFreeBuffer(lpProp);
607 MAPIFreeBuffer(SRowSet);
608 MAPIFreeBuffer(SPropTagArray);
609 mapitest_print_retval_clean(mt, "nspi_GetMatches", retval);
610 if (retval != MAPI_E_SUCCESS) {
611 MAPIFreeBuffer(MIds);
612 talloc_free(mem_ctx);
617 SRowSet = talloc_zero(mem_ctx, struct SRowSet);
618 retval = nspi_QueryRows(nspi_ctx, mem_ctx, NULL, MIds, 1, &SRowSet);
619 mapitest_print_retval_clean(mt, "nspi_QueryRows", retval);
620 if (retval != MAPI_E_SUCCESS) {
621 MAPIFreeBuffer(MIds);
622 MAPIFreeBuffer(SRowSet);
623 talloc_free(mem_ctx);
626 if (SRowSet->cRows != 1) {
627 mapitest_print(mem_ctx, "unexpected number of rows: %i\n", SRowSet->cRows);
628 MAPIFreeBuffer(MIds);
629 MAPIFreeBuffer(SRowSet);
630 talloc_free(mem_ctx);
633 original_office_location = (const char *)find_SPropValue_data(&(SRowSet->aRow[0]), PR_OFFICE_LOCATION);
634 mapitest_print(mt, "original PR_OFFICE_LOCATION value: %s\n", original_office_location);
636 /* Build the SRow and SPropTagArray for NspiModProps */
637 pRow = talloc_zero(mem_ctx, struct SRow);
638 modProp.ulPropTag = PR_OFFICE_LOCATION;
639 modProp.value.lpszA = "MT office location";
640 SRow_addprop(pRow, modProp);
642 pPropTags = set_SPropTagArray(mem_ctx, 0x1, PR_OFFICE_LOCATION);
643 retval = nspi_ModProps(nspi_ctx, mem_ctx, MIds->aulPropTag[0], pPropTags, pRow);
644 mapitest_print_retval_clean(mt, "nspi_ModProps", retval);
645 MAPIFreeBuffer(pRow);
647 if (retval != MAPI_E_SUCCESS) {
648 MAPIFreeBuffer(MIds);
649 MAPIFreeBuffer(pPropTags);
650 talloc_free(mem_ctx);
654 /* Check that the property was set correctly */
655 SRowSet = talloc_zero(mem_ctx, struct SRowSet);
656 retval = nspi_QueryRows(nspi_ctx, mem_ctx, NULL, MIds, 1, &SRowSet);
657 mapitest_print_retval_clean(mt, "nspi_QueryRows", retval);
658 if (retval != MAPI_E_SUCCESS) {
659 MAPIFreeBuffer(MIds);
660 MAPIFreeBuffer(SRowSet);
661 talloc_free(mem_ctx);
664 if (SRowSet->cRows != 1) {
665 mapitest_print(mem_ctx, "unexpected number of rows: %i\n", SRowSet->cRows);
666 MAPIFreeBuffer(MIds);
667 MAPIFreeBuffer(SRowSet);
668 talloc_free(mem_ctx);
671 if (strcmp((const char *)find_SPropValue_data(&(SRowSet->aRow[0]), PR_OFFICE_LOCATION), "MT office location") != 0) {
672 mapitest_print(mt, "PR_OFFICE_LOCATION string value mismatch: %s", (const char *)find_SPropValue_data(&(SRowSet->aRow[0]), PR_OFFICE_LOCATION));
675 mapitest_print(mt, "correctly set PR_OFFICE_LOCATION\n");
678 /* try to reset the office location back to the original value */
679 pRow = talloc_zero(mem_ctx, struct SRow);
680 modProp.ulPropTag = PR_OFFICE_LOCATION;
681 modProp.value.lpszA = original_office_location;
682 SRow_addprop(pRow, modProp);
684 retval = nspi_ModProps(nspi_ctx, mem_ctx, MIds->aulPropTag[0], pPropTags, pRow);
685 mapitest_print_retval_clean(mt, "nspi_ModProps (reset original value)", retval);
686 if (retval != MAPI_E_SUCCESS) {
690 MAPIFreeBuffer(MIds);
691 MAPIFreeBuffer(pPropTags);
692 MAPIFreeBuffer(pRow);
694 talloc_free(mem_ctx);
701 \details Test the NspiGetSpecialTable RPC operation (0x0c)
703 \param mt pointer on the top-level mapitest structure
705 \return true on success, otherwise false
707 _PUBLIC_ bool mapitest_nspi_GetSpecialTable(struct mapitest *mt)
710 enum MAPISTATUS retval;
711 struct nspi_context *nspi_ctx;
712 struct SRowSet *SRowSet;
714 mem_ctx = talloc_named(NULL, 0, "mapitest_nspi_GetSpecialTable");
715 nspi_ctx = (struct nspi_context *) mt->session->nspi->ctx;
717 SRowSet = talloc_zero(mem_ctx, struct SRowSet);
718 retval = nspi_GetSpecialTable(nspi_ctx, mem_ctx, 0x0, &SRowSet);
719 MAPIFreeBuffer(SRowSet);
720 mapitest_print_retval_clean(mt, "NspiGetSpecialTable (Hierarchy Table)", retval);
722 if (retval != MAPI_E_SUCCESS) {
723 talloc_free(mem_ctx);
727 SRowSet = talloc_zero(mt->mem_ctx, struct SRowSet);
728 retval = nspi_GetSpecialTable(nspi_ctx, mem_ctx, 0x2, &SRowSet);
729 MAPIFreeBuffer(SRowSet);
730 mapitest_print_retval_clean(mt, "NspiGetSpecialTable (Address Creation Template)", retval);
731 talloc_free(mem_ctx);
733 if (retval == MAPI_E_SUCCESS) {
742 \details Test the NspiGetTemplateInfo RPC operation (0x0d)
744 \param mt pointer on the top-level mapitest structure
746 \return true on success, otherwise false
748 _PUBLIC_ bool mapitest_nspi_GetTemplateInfo(struct mapitest *mt)
751 enum MAPISTATUS retval;
752 struct nspi_context *nspi_ctx;
753 struct SRow *ppData = NULL;
755 mem_ctx = talloc_named(NULL, 0, "mapitest_nspi_GetTemplateInfo");
756 nspi_ctx = (struct nspi_context *) mt->session->nspi->ctx;
758 ppData = talloc_zero(mem_ctx, struct SRow);
759 retval = nspi_GetTemplateInfo(nspi_ctx, mem_ctx,
760 TI_TEMPLATE|TI_SCRIPT|TI_EMT|TI_HELPFILE_NAME|TI_HELPFILE_CONTENTS,
762 mapitest_print_retval_clean(mt, "NspiGetTemplateInfo", retval);
763 MAPIFreeBuffer(ppData);
764 talloc_free(mem_ctx);
766 if (retval == MAPI_E_SUCCESS) {
775 \details Test the NspiModLinkAtt RPC operation (0x0e)
777 \param mt pointer on the top-level mapitest structure
779 \return true on success, otherwise false
781 _PUBLIC_ bool mapitest_nspi_ModLinkAtt(struct mapitest *mt)
783 enum MAPISTATUS retval;
784 struct nspi_context *nspi_ctx;
785 /* struct SPropTagArray *MIds; */
786 struct BinaryArray_r *lpEntryIds;
788 nspi_ctx = (struct nspi_context *) mt->session->nspi->ctx;
790 lpEntryIds = talloc_zero(mt->mem_ctx, struct BinaryArray_r);
791 lpEntryIds->cValues = 0;
792 lpEntryIds->lpbin = NULL;
794 retval = nspi_ModLinkAtt(nspi_ctx, false, PR_EMS_AB_REPORTS, 0x0, lpEntryIds);
795 mapitest_print_retval_clean(mt, "NspiModLinkAtt", retval);
796 MAPIFreeBuffer(lpEntryIds);
798 if (retval == MAPI_E_SUCCESS) {
808 \details Test the NspiQueryColumns RPC operation (0x10)
810 \param mt pointer on the top-level mapitest structure
812 \return true on success, otherwise false
814 _PUBLIC_ bool mapitest_nspi_QueryColumns(struct mapitest *mt)
817 enum MAPISTATUS retval;
818 struct nspi_context *nspi_ctx;
819 struct SPropTagArray *SPropTagArray = NULL;
821 mem_ctx = talloc_named(NULL, 0, "mapitest_nspi_QueryColumns");
822 nspi_ctx = (struct nspi_context *) mt->session->nspi->ctx;
824 SPropTagArray = talloc_zero(mem_ctx, struct SPropTagArray);
826 retval = nspi_QueryColumns(nspi_ctx, mem_ctx, true, &SPropTagArray);
827 if (retval != MAPI_E_SUCCESS) {
828 mapitest_print_retval_clean(mt, "NspiQueryColumns", retval);
829 MAPIFreeBuffer(SPropTagArray);
830 talloc_free(mem_ctx);
835 mapitest_print(mt, "* %d columns returned\n", SPropTagArray->cValues);
836 mapitest_print_retval_clean(mt, "NspiQueryColumns", retval);
837 MAPIFreeBuffer(SPropTagArray);
839 talloc_free(mem_ctx);
846 \details Test the NspiGetNamesFromIDs RPC operation (0x11)
848 \param mt pointer on the top-level mapitest structure
850 \return true on success, otherwise false
852 _PUBLIC_ bool mapitest_nspi_GetNamesFromIDs(struct mapitest *mt)
855 enum MAPISTATUS retval;
856 struct nspi_context *nspi_ctx;
857 struct SPropTagArray *ppReturnedPropTags;
858 struct PropertyNameSet_r *ppNames;
860 mem_ctx = talloc_named(NULL, 0, "mapitest_nspi_GetNamesFromIDs");
861 nspi_ctx = (struct nspi_context *) mt->session->nspi->ctx;
864 ppReturnedPropTags = talloc_zero(mem_ctx, struct SPropTagArray);
865 ppNames = talloc_zero(mem_ctx, struct PropertyNameSet_r);
866 retval = nspi_GetNamesFromIDs(nspi_ctx, mem_ctx, NULL, NULL, &ppReturnedPropTags, &ppNames);
867 mapitest_print_retval_clean(mt, "NspiGetNamesFromIDs", retval);
868 MAPIFreeBuffer(ppReturnedPropTags);
869 MAPIFreeBuffer(ppNames);
870 talloc_free(mem_ctx);
872 if (retval == MAPI_E_SUCCESS) {
881 \details Test the NspiGetIDsFromNames RPC operation (0x12)
883 \param mt pointer on the top-level mapitest structure
885 \return true on success, otherwise false
887 _PUBLIC_ bool mapitest_nspi_GetIDsFromNames(struct mapitest *mt)
890 enum MAPISTATUS retval;
891 struct nspi_context *nspi_ctx;
892 struct SPropTagArray *ppReturnedPropTags;
893 struct PropertyNameSet_r *ppNames;
895 mem_ctx = talloc_named(NULL, 0, "mapitest_nspi_GetIDsFromNames");
896 nspi_ctx = (struct nspi_context *) mt->session->nspi->ctx;
899 ppReturnedPropTags = talloc_zero(mem_ctx, struct SPropTagArray);
900 ppNames = talloc_zero(mem_ctx, struct PropertyNameSet_r);
901 retval = nspi_GetNamesFromIDs(nspi_ctx, mem_ctx, NULL, NULL, &ppReturnedPropTags, &ppNames);
902 mapitest_print_retval_clean(mt, "NspiGetNamesFromIDs", retval);
903 MAPIFreeBuffer(ppReturnedPropTags);
905 if ( (retval != MAPI_E_SUCCESS) || !ppNames ) {
906 MAPIFreeBuffer(ppNames);
907 talloc_free(mem_ctx);
911 ppReturnedPropTags = talloc_zero(mem_ctx, struct SPropTagArray);
912 retval = nspi_GetIDsFromNames(nspi_ctx, mem_ctx, true, ppNames->cNames, ppNames->aNames, &ppReturnedPropTags);
913 mapitest_print_retval_clean(mt, "NspiGetIDsFromNames", retval);
914 MAPIFreeBuffer(ppReturnedPropTags);
915 MAPIFreeBuffer(ppNames);
916 talloc_free(mem_ctx);
918 if (retval == MAPI_E_SUCCESS) {
927 \details Test the NspiResolveNames and NspiResolveNamesW RPC
928 operations (0x13 and 0x14)
930 \param mt pointer on the top-level mapitest structure
932 \return true on success, otherwise false
934 _PUBLIC_ bool mapitest_nspi_ResolveNames(struct mapitest *mt)
936 enum MAPISTATUS retval;
937 struct SPropTagArray *SPropTagArray = NULL;
938 struct SRowSet *SRowSet = NULL;
939 struct PropertyTagArray_r *flaglist = NULL;
940 const char *username[2];
941 const char *username_err[2];
943 /* Build the username array */
944 username[0] = (const char *)mt->profile->mailbox;
946 /* Build the err username array */
947 username_err[0] = talloc_asprintf(mt->mem_ctx, "%s%s", mt->info.szDNPrefix, "nspi_resolve_testcase");
948 username_err[1] = NULL;
950 SPropTagArray = set_SPropTagArray(mt->mem_ctx, 0xd,
959 PR_SEND_INTERNET_ENCODING,
962 PR_TRANSMITTABLE_DISPLAY_NAME,
963 PR_7BIT_DISPLAY_NAME);
965 /* Test with existing username */
966 /* NspiResolveNames (0x13) */
967 retval = ResolveNames(mt->session, (const char **)username, SPropTagArray, &SRowSet, &flaglist, 0);
968 mapitest_print_retval_clean(mt, "NspiResolveNames - existing", retval);
969 if (retval != MAPI_E_SUCCESS) {
970 MAPIFreeBuffer(SPropTagArray);
974 mapitest_print(mt, "\tNULL flaglist, which wasn't expected\n");
975 MAPIFreeBuffer(SPropTagArray);
978 if (flaglist->aulPropTag[0] != MAPI_RESOLVED) {
979 mapitest_print(mt, "Expected 2 (MAPI_RESOLVED), but NspiResolveNames returned: %i\n", flaglist->aulPropTag[0]);
981 mapitest_print(mt, "\tGot expected resolution flag\n");
983 talloc_free(flaglist);
984 talloc_free(SRowSet);
985 if (retval != MAPI_E_SUCCESS) {
986 MAPIFreeBuffer(SPropTagArray);
990 /* NspiResolveNamesW (0x14) */
991 retval = ResolveNames(mt->session, (const char **)username, SPropTagArray, &SRowSet, &flaglist, MAPI_UNICODE);
992 mapitest_print_retval_clean(mt, "NspiResolveNamesW - existing", retval);
993 if (flaglist->aulPropTag[0] != MAPI_RESOLVED) {
994 mapitest_print(mt, "Expected 2 (MAPI_RESOLVED), but NspiResolveNamesW returned: %i\n", flaglist->aulPropTag[0]);
996 mapitest_print(mt, "\tGot expected resolution flag\n");
998 talloc_free(flaglist);
999 talloc_free(SRowSet);
1000 if (retval != MAPI_E_SUCCESS) {
1001 MAPIFreeBuffer(SPropTagArray);
1005 /* Test with non-existant username */
1006 /* NspiResolveNames (0x13) */
1007 retval = ResolveNames(mt->session, (const char **)username_err, SPropTagArray, &SRowSet, &flaglist, 0);
1008 mapitest_print_retval_clean(mt, "NspiResolveNames - non existant user name", retval);
1009 if (flaglist->aulPropTag[0] != MAPI_UNRESOLVED) {
1010 mapitest_print(mt, "Expected 0 (MAPI_UNRESOLVED), but NspiResolveNames returned: %i\n", flaglist->aulPropTag[0]);
1012 mapitest_print(mt, "\tGot expected resolution flag\n");
1014 talloc_free(flaglist);
1015 talloc_free(SRowSet);
1016 if (retval != MAPI_E_SUCCESS) {
1017 MAPIFreeBuffer(SPropTagArray);
1021 /* NspiResolveNamesW (0x14) */
1022 retval = ResolveNames(mt->session, (const char **)username_err, SPropTagArray, &SRowSet, &flaglist, MAPI_UNICODE);
1023 mapitest_print_retval_clean(mt, "NspiResolveNamesW - non existant user name", retval);
1024 if (flaglist->aulPropTag[0] != MAPI_UNRESOLVED) {
1025 mapitest_print(mt, "Expected 0 (MAPI_UNRESOLVED), but NspiResolveNamesW returned: %i\n", flaglist->aulPropTag[0]);
1027 mapitest_print(mt, "\tGot expected resolution flag\n");
1029 talloc_free(flaglist);
1030 talloc_free(SRowSet);
1031 if (retval != MAPI_E_SUCCESS) {
1032 MAPIFreeBuffer(SPropTagArray);
1035 MAPIFreeBuffer(SPropTagArray);
1040 \details Test the GetGALTable function
1042 \param mt pointer to the top-level mapitest structure
1044 \return true on success, otherwise false
1046 _PUBLIC_ bool mapitest_nspi_GetGALTable(struct mapitest *mt)
1048 struct SPropTagArray *SPropTagArray;
1049 struct SRowSet *SRowSet;
1050 enum MAPISTATUS retval;
1054 uint32_t rowsFetched = 0;
1055 uint32_t totalRowsFetched = 0;
1058 SPropTagArray = set_SPropTagArray(mt->mem_ctx, 0xc,
1061 PR_DISPLAY_NAME_UNICODE,
1062 PR_EMAIL_ADDRESS_UNICODE,
1065 PR_ADDRTYPE_UNICODE,
1066 PR_OFFICE_TELEPHONE_NUMBER_UNICODE,
1067 PR_OFFICE_LOCATION_UNICODE,
1069 PR_COMPANY_NAME_UNICODE,
1070 PR_ACCOUNT_UNICODE);
1073 ulFlags = TABLE_START;
1075 retval = GetGALTable(mt->session, SPropTagArray, &SRowSet, count, ulFlags);
1076 mapitest_print_retval_clean(mt, "GetGALTable", retval);
1077 if ((!SRowSet) || (!(SRowSet->aRow))) {
1081 rowsFetched = SRowSet->cRows;
1082 totalRowsFetched += rowsFetched;
1084 for (i = 0; i < rowsFetched; i++) {
1085 mapitest_print_PAB_entry(mt, &SRowSet->aRow[i]);
1088 ulFlags = TABLE_CUR;
1089 MAPIFreeBuffer(SRowSet);
1090 } while (rowsFetched == count);
1092 if (totalRowsFetched < 1) {
1093 /* We should always have at least ourselves in the list */
1094 /* So if we got no rows at all, there is a problem */
1098 MAPIFreeBuffer(SPropTagArray);