2 Unix SMB/CIFS implementation.
3 test suite for lsa rpc operations
5 Copyright (C) Andrew Tridgell 2003
6 Copyright (C) Andrew Bartlett <abartlet@samba.org> 2004-2005
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/>.
23 #include "torture/torture.h"
24 #include "librpc/gen_ndr/ndr_lsa_c.h"
25 #include "librpc/gen_ndr/netlogon.h"
26 #include "librpc/gen_ndr/ndr_drsblobs.h"
27 #include "librpc/gen_ndr/ndr_netlogon_c.h"
28 #include "lib/events/events.h"
29 #include "libcli/security/security.h"
30 #include "libcli/auth/libcli_auth.h"
31 #include "torture/rpc/torture_rpc.h"
32 #include "param/param.h"
33 #include "../lib/crypto/crypto.h"
34 #define TEST_MACHINENAME "lsatestmach"
35 #define TRUSTPW "12345678"
37 static void init_lsa_String(struct lsa_String *name, const char *s)
42 static bool test_OpenPolicy(struct dcerpc_binding_handle *b,
43 struct torture_context *tctx)
45 struct lsa_ObjectAttribute attr;
46 struct policy_handle handle;
47 struct lsa_QosInfo qos;
48 struct lsa_OpenPolicy r;
49 uint16_t system_name = '\\';
51 torture_comment(tctx, "\nTesting OpenPolicy\n");
54 qos.impersonation_level = 2;
56 qos.effective_only = 0;
60 attr.object_name = NULL;
65 r.in.system_name = &system_name;
67 r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
68 r.out.handle = &handle;
70 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_OpenPolicy_r(b, tctx, &r),
73 torture_assert_ntstatus_ok(tctx,
80 static bool test_OpenPolicy_fail(struct dcerpc_binding_handle *b,
81 struct torture_context *tctx)
83 struct lsa_ObjectAttribute attr;
84 struct policy_handle handle;
85 struct lsa_QosInfo qos;
86 struct lsa_OpenPolicy r;
87 uint16_t system_name = '\\';
90 torture_comment(tctx, "\nTesting OpenPolicy_fail\n");
93 qos.impersonation_level = 2;
95 qos.effective_only = 0;
99 attr.object_name = NULL;
101 attr.sec_desc = NULL;
104 r.in.system_name = &system_name;
106 r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
107 r.out.handle = &handle;
109 status = dcerpc_lsa_OpenPolicy_r(b, tctx, &r);
110 if (!NT_STATUS_IS_OK(status)) {
111 if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) {
112 torture_comment(tctx,
113 "OpenPolicy correctly returned with "
119 torture_assert_ntstatus_equal(tctx,
121 NT_STATUS_ACCESS_DENIED,
122 "OpenPolicy return value should "
127 if (!NT_STATUS_IS_OK(r.out.result)) {
128 if (NT_STATUS_EQUAL(r.out.result, NT_STATUS_ACCESS_DENIED) ||
129 NT_STATUS_EQUAL(r.out.result, NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED)) {
130 torture_comment(tctx,
131 "OpenPolicy correctly returned with "
133 nt_errstr(r.out.result));
138 torture_assert_ntstatus_equal(tctx,
141 "OpenPolicy return value should be "
148 bool test_lsa_OpenPolicy2_ex(struct dcerpc_binding_handle *b,
149 struct torture_context *tctx,
150 struct policy_handle **handle,
151 NTSTATUS expected_status)
153 struct lsa_ObjectAttribute attr;
154 struct lsa_QosInfo qos;
155 struct lsa_OpenPolicy2 r;
158 torture_comment(tctx, "\nTesting OpenPolicy2\n");
160 *handle = talloc(tctx, struct policy_handle);
166 qos.impersonation_level = 2;
167 qos.context_mode = 1;
168 qos.effective_only = 0;
171 attr.root_dir = NULL;
172 attr.object_name = NULL;
174 attr.sec_desc = NULL;
177 r.in.system_name = "\\";
179 r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
180 r.out.handle = *handle;
182 status = dcerpc_lsa_OpenPolicy2_r(b, tctx, &r);
183 torture_assert_ntstatus_equal(tctx, status, expected_status,
184 "OpenPolicy2 failed");
185 if (!NT_STATUS_IS_OK(expected_status)) {
189 torture_assert_ntstatus_ok(tctx,
191 "OpenPolicy2 failed");
197 bool test_lsa_OpenPolicy2(struct dcerpc_binding_handle *b,
198 struct torture_context *tctx,
199 struct policy_handle **handle)
201 return test_lsa_OpenPolicy2_ex(b, tctx, handle, NT_STATUS_OK);
204 static bool test_OpenPolicy2_fail(struct dcerpc_binding_handle *b,
205 struct torture_context *tctx)
207 struct lsa_ObjectAttribute attr;
208 struct policy_handle handle;
209 struct lsa_QosInfo qos;
210 struct lsa_OpenPolicy2 r;
213 torture_comment(tctx, "\nTesting OpenPolicy2_fail\n");
216 qos.impersonation_level = 2;
217 qos.context_mode = 1;
218 qos.effective_only = 0;
221 attr.root_dir = NULL;
222 attr.object_name = NULL;
224 attr.sec_desc = NULL;
227 r.in.system_name = "\\";
229 r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
230 r.out.handle = &handle;
232 status = dcerpc_lsa_OpenPolicy2_r(b, tctx, &r);
233 if (!NT_STATUS_IS_OK(status)) {
234 if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) {
235 torture_comment(tctx,
236 "OpenPolicy2 correctly returned with "
242 torture_assert_ntstatus_equal(tctx,
244 NT_STATUS_ACCESS_DENIED,
245 "OpenPolicy2 return value should "
250 if (NT_STATUS_EQUAL(r.out.result, NT_STATUS_ACCESS_DENIED) ||
251 NT_STATUS_EQUAL(r.out.result, NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED)) {
252 torture_comment(tctx,
253 "OpenPolicy2 correctly returned with "
255 nt_errstr(r.out.result));
260 "OpenPolicy2 return value should be "
261 "ACCESS_DENIED or RPC_PROTSEQ_NOT_SUPPORTED");
266 static bool test_LookupNames(struct dcerpc_binding_handle *b,
267 struct torture_context *tctx,
268 struct policy_handle *handle,
269 struct lsa_TransNameArray *tnames)
271 struct lsa_LookupNames r;
272 struct lsa_TransSidArray sids;
273 struct lsa_RefDomainList *domains = NULL;
274 struct lsa_String *names;
279 torture_comment(tctx, "\nTesting LookupNames with %d names\n", tnames->count);
287 input_idx = talloc_array(tctx, uint32_t, tnames->count);
288 names = talloc_array(tctx, struct lsa_String, tnames->count);
290 for (i=0;i<tnames->count;i++) {
291 if (tnames->names[i].sid_type != SID_NAME_UNKNOWN) {
292 init_lsa_String(&names[r.in.num_names], tnames->names[i].name.string);
293 input_idx[r.in.num_names] = i;
298 r.in.handle = handle;
303 r.out.count = &count;
305 r.out.domains = &domains;
307 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_LookupNames_r(b, tctx, &r),
308 "LookupNames failed");
309 if (NT_STATUS_EQUAL(r.out.result, STATUS_SOME_UNMAPPED) ||
310 NT_STATUS_EQUAL(r.out.result, NT_STATUS_NONE_MAPPED)) {
311 for (i=0;i< r.in.num_names;i++) {
312 if (i < count && sids.sids[i].sid_type == SID_NAME_UNKNOWN) {
313 torture_comment(tctx, "LookupName of %s was unmapped\n",
314 tnames->names[i].name.string);
315 } else if (i >=count) {
316 torture_comment(tctx, "LookupName of %s failed to return a result\n",
317 tnames->names[i].name.string);
320 torture_comment(tctx, "LookupNames failed - %s\n",
321 nt_errstr(r.out.result));
323 } else if (!NT_STATUS_IS_OK(r.out.result)) {
324 torture_comment(tctx, "LookupNames failed - %s\n",
325 nt_errstr(r.out.result));
329 for (i=0;i< r.in.num_names;i++) {
331 if (sids.sids[i].sid_type != tnames->names[input_idx[i]].sid_type) {
332 torture_comment(tctx, "LookupName of %s got unexpected name type: %s\n",
333 tnames->names[input_idx[i]].name.string,
334 sid_type_lookup(sids.sids[i].sid_type));
337 if ((sids.sids[i].sid_type == SID_NAME_DOMAIN) &&
338 (sids.sids[i].rid != (uint32_t)-1)) {
339 torture_comment(tctx, "LookupName of %s got unexpected rid: %d\n",
340 tnames->names[input_idx[i]].name.string, sids.sids[i].rid);
343 } else if (i >=count) {
344 torture_comment(tctx, "LookupName of %s failed to return a result\n",
345 tnames->names[input_idx[i]].name.string);
349 torture_comment(tctx, "\n");
354 static bool test_LookupNames_bogus(struct dcerpc_binding_handle *b,
355 struct torture_context *tctx,
356 struct policy_handle *handle)
358 struct lsa_LookupNames r;
359 struct lsa_TransSidArray sids;
360 struct lsa_RefDomainList *domains = NULL;
361 struct lsa_String names[1];
364 torture_comment(tctx, "\nTesting LookupNames with bogus name\n");
369 init_lsa_String(&names[0], "NT AUTHORITY\\BOGUS");
371 r.in.handle = handle;
377 r.out.count = &count;
379 r.out.domains = &domains;
381 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_LookupNames_r(b, tctx, &r),
382 "LookupNames bogus failed");
383 if (!NT_STATUS_EQUAL(r.out.result, NT_STATUS_NONE_MAPPED)) {
384 torture_comment(tctx, "LookupNames failed - %s\n",
385 nt_errstr(r.out.result));
389 torture_comment(tctx, "\n");
394 static bool test_LookupNames_NULL(struct dcerpc_binding_handle *b,
395 struct torture_context *tctx,
396 struct policy_handle *handle)
398 struct lsa_LookupNames r;
399 struct lsa_TransSidArray sids;
400 struct lsa_RefDomainList *domains = NULL;
401 struct lsa_String names[1];
404 torture_comment(tctx, "\nTesting LookupNames with NULL name\n");
409 names[0].string = NULL;
411 r.in.handle = handle;
417 r.out.count = &count;
419 r.out.domains = &domains;
421 /* nt4 returns NT_STATUS_NONE_MAPPED with sid_type
422 * SID_NAME_UNKNOWN, rid 0, and sid_index -1;
424 * w2k3/w2k8 return NT_STATUS_OK with sid_type
425 * SID_NAME_DOMAIN, rid -1 and sid_index 0 and BUILTIN domain
428 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_LookupNames_r(b, tctx, &r),
429 "LookupNames with NULL name failed");
430 torture_assert_ntstatus_ok(tctx, r.out.result,
431 "LookupNames with NULL name failed");
433 torture_comment(tctx, "\n");
438 static bool test_LookupNames_wellknown(struct dcerpc_binding_handle *b,
439 struct torture_context *tctx,
440 struct policy_handle *handle)
442 struct lsa_TranslatedName name;
443 struct lsa_TransNameArray tnames;
446 torture_comment(tctx, "Testing LookupNames with well known names\n");
448 tnames.names = &name;
450 name.name.string = "NT AUTHORITY\\SYSTEM";
451 name.sid_type = SID_NAME_WKN_GRP;
452 ret &= test_LookupNames(b, tctx, handle, &tnames);
454 name.name.string = "NT AUTHORITY\\ANONYMOUS LOGON";
455 name.sid_type = SID_NAME_WKN_GRP;
456 ret &= test_LookupNames(b, tctx, handle, &tnames);
458 name.name.string = "NT AUTHORITY\\Authenticated Users";
459 name.sid_type = SID_NAME_WKN_GRP;
460 ret &= test_LookupNames(b, tctx, handle, &tnames);
463 name.name.string = "NT AUTHORITY";
464 ret &= test_LookupNames(b, tctx, handle, &tnames);
466 name.name.string = "NT AUTHORITY\\";
467 ret &= test_LookupNames(b, tctx, handle, &tnames);
470 name.name.string = "BUILTIN\\";
471 name.sid_type = SID_NAME_DOMAIN;
472 ret &= test_LookupNames(b, tctx, handle, &tnames);
474 name.name.string = "BUILTIN\\Administrators";
475 name.sid_type = SID_NAME_ALIAS;
476 ret &= test_LookupNames(b, tctx, handle, &tnames);
478 name.name.string = "SYSTEM";
479 name.sid_type = SID_NAME_WKN_GRP;
480 ret &= test_LookupNames(b, tctx, handle, &tnames);
482 name.name.string = "Everyone";
483 name.sid_type = SID_NAME_WKN_GRP;
484 ret &= test_LookupNames(b, tctx, handle, &tnames);
488 static bool test_LookupNames2(struct dcerpc_binding_handle *b,
489 struct torture_context *tctx,
490 struct policy_handle *handle,
491 struct lsa_TransNameArray2 *tnames,
494 struct lsa_LookupNames2 r;
495 struct lsa_TransSidArray2 sids;
496 struct lsa_RefDomainList *domains = NULL;
497 struct lsa_String *names;
502 torture_comment(tctx, "\nTesting LookupNames2 with %d names\n", tnames->count);
509 input_idx = talloc_array(tctx, uint32_t, tnames->count);
510 names = talloc_array(tctx, struct lsa_String, tnames->count);
512 for (i=0;i<tnames->count;i++) {
513 if (tnames->names[i].sid_type != SID_NAME_UNKNOWN) {
514 init_lsa_String(&names[r.in.num_names], tnames->names[i].name.string);
515 input_idx[r.in.num_names] = i;
520 r.in.handle = handle;
525 r.in.lookup_options = 0;
526 r.in.client_revision = 0;
527 r.out.count = &count;
529 r.out.domains = &domains;
531 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_LookupNames2_r(b, tctx, &r),
532 "LookupNames2 failed");
533 torture_assert_ntstatus_ok(tctx, r.out.result, "LookupNames2 failed");
536 torture_assert_int_equal(tctx, count, sids.count,
537 "unexpected number of results returned");
538 if (sids.count > 0) {
539 torture_assert(tctx, sids.sids, "invalid sid buffer");
543 torture_comment(tctx, "\n");
549 static bool test_LookupNames3(struct dcerpc_binding_handle *b,
550 struct torture_context *tctx,
551 struct policy_handle *handle,
552 struct lsa_TransNameArray2 *tnames,
555 struct lsa_LookupNames3 r;
556 struct lsa_TransSidArray3 sids;
557 struct lsa_RefDomainList *domains = NULL;
558 struct lsa_String *names;
563 torture_comment(tctx, "\nTesting LookupNames3 with %d names\n", tnames->count);
570 input_idx = talloc_array(tctx, uint32_t, tnames->count);
571 names = talloc_array(tctx, struct lsa_String, tnames->count);
572 for (i=0;i<tnames->count;i++) {
573 if (tnames->names[i].sid_type != SID_NAME_UNKNOWN) {
574 init_lsa_String(&names[r.in.num_names], tnames->names[i].name.string);
575 input_idx[r.in.num_names] = i;
580 r.in.handle = handle;
585 r.in.lookup_options = 0;
586 r.in.client_revision = 0;
587 r.out.count = &count;
589 r.out.domains = &domains;
591 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_LookupNames3_r(b, tctx, &r),
592 "LookupNames3 failed");
593 torture_assert_ntstatus_ok(tctx, r.out.result,
594 "LookupNames3 failed");
597 torture_assert_int_equal(tctx, count, sids.count,
598 "unexpected number of results returned");
599 if (sids.count > 0) {
600 torture_assert(tctx, sids.sids, "invalid sid buffer");
604 torture_comment(tctx, "\n");
609 static bool test_LookupNames4(struct dcerpc_binding_handle *b,
610 struct torture_context *tctx,
611 struct lsa_TransNameArray2 *tnames,
614 struct lsa_LookupNames4 r;
615 struct lsa_TransSidArray3 sids;
616 struct lsa_RefDomainList *domains = NULL;
617 struct lsa_String *names;
622 torture_comment(tctx, "\nTesting LookupNames4 with %d names\n", tnames->count);
629 input_idx = talloc_array(tctx, uint32_t, tnames->count);
630 names = talloc_array(tctx, struct lsa_String, tnames->count);
631 for (i=0;i<tnames->count;i++) {
632 if (tnames->names[i].sid_type != SID_NAME_UNKNOWN) {
633 init_lsa_String(&names[r.in.num_names], tnames->names[i].name.string);
634 input_idx[r.in.num_names] = i;
639 r.in.num_names = tnames->count;
644 r.in.lookup_options = 0;
645 r.in.client_revision = 0;
646 r.out.count = &count;
648 r.out.domains = &domains;
650 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_LookupNames4_r(b, tctx, &r),
651 "LookupNames4 failed");
653 if (!NT_STATUS_IS_OK(r.out.result)) {
654 if (NT_STATUS_EQUAL(r.out.result, NT_STATUS_NONE_MAPPED)) {
655 torture_comment(tctx,
656 "LookupNames4 failed: %s - not considered as an error",
657 nt_errstr(r.out.result));
662 torture_assert_ntstatus_ok(tctx,
664 "LookupNames4 failed");
667 torture_assert_int_equal(tctx, count, sids.count,
668 "unexpected number of results returned");
669 if (sids.count > 0) {
670 torture_assert(tctx, sids.sids, "invalid sid buffer");
674 torture_comment(tctx, "\n");
679 static bool test_LookupNames4_fail(struct dcerpc_binding_handle *b,
680 struct torture_context *tctx)
682 struct lsa_LookupNames4 r;
683 struct lsa_TransSidArray3 sids;
684 struct lsa_RefDomainList *domains = NULL;
685 struct lsa_String *names = NULL;
689 torture_comment(tctx, "\nTesting LookupNames4_fail");
696 r.in.num_names = count;
701 r.in.lookup_options = 0;
702 r.in.client_revision = 0;
703 r.out.count = &count;
705 r.out.domains = &domains;
707 status = dcerpc_lsa_LookupNames4_r(b, tctx, &r);
708 if (!NT_STATUS_IS_OK(status)) {
709 if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) {
710 torture_comment(tctx,
711 "LookupNames4 correctly returned with "
717 torture_assert_ntstatus_equal(tctx,
719 NT_STATUS_ACCESS_DENIED,
720 "LookupNames4 return value should "
725 if (!NT_STATUS_IS_OK(r.out.result)) {
726 if (NT_STATUS_EQUAL(r.out.result, NT_STATUS_ACCESS_DENIED) ||
727 NT_STATUS_EQUAL(r.out.result, NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED)) {
728 torture_comment(tctx,
729 "LookupSids3 correctly returned with "
731 nt_errstr(r.out.result));
737 "LookupNames4 return value should be "
738 "ACCESS_DENIED or RPC_PROTSEQ_NOT_SUPPORTED");
744 static bool test_LookupSids(struct dcerpc_binding_handle *b,
745 struct torture_context *tctx,
746 struct policy_handle *handle,
747 struct lsa_SidArray *sids)
749 struct lsa_LookupSids r;
750 struct lsa_TransNameArray names;
751 struct lsa_RefDomainList *domains = NULL;
752 uint32_t count = sids->num_sids;
754 torture_comment(tctx, "\nTesting LookupSids\n");
759 r.in.handle = handle;
764 r.out.count = &count;
765 r.out.names = &names;
766 r.out.domains = &domains;
768 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_LookupSids_r(b, tctx, &r),
769 "LookupSids failed");
770 if (!NT_STATUS_IS_OK(r.out.result) &&
771 !NT_STATUS_EQUAL(r.out.result, STATUS_SOME_UNMAPPED)) {
772 torture_comment(tctx, "LookupSids failed - %s\n",
773 nt_errstr(r.out.result));
777 torture_comment(tctx, "\n");
779 if (!test_LookupNames(b, tctx, handle, &names)) {
787 static bool test_LookupSids2(struct dcerpc_binding_handle *b,
788 struct torture_context *tctx,
789 struct policy_handle *handle,
790 struct lsa_SidArray *sids)
792 struct lsa_LookupSids2 r;
793 struct lsa_TransNameArray2 names;
794 struct lsa_RefDomainList *domains = NULL;
795 uint32_t count = sids->num_sids;
797 torture_comment(tctx, "\nTesting LookupSids2\n");
802 r.in.handle = handle;
807 r.in.lookup_options = 0;
808 r.in.client_revision = 0;
809 r.out.count = &count;
810 r.out.names = &names;
811 r.out.domains = &domains;
813 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_LookupSids2_r(b, tctx, &r),
814 "LookupSids2 failed");
815 if (!NT_STATUS_IS_OK(r.out.result) &&
816 !NT_STATUS_EQUAL(r.out.result, STATUS_SOME_UNMAPPED)) {
817 torture_comment(tctx, "LookupSids2 failed - %s\n",
818 nt_errstr(r.out.result));
822 torture_comment(tctx, "\n");
824 if (!test_LookupNames2(b, tctx, handle, &names, false)) {
828 if (!test_LookupNames3(b, tctx, handle, &names, false)) {
835 static bool test_LookupSids3(struct dcerpc_binding_handle *b,
836 struct torture_context *tctx,
837 struct lsa_SidArray *sids)
839 struct lsa_LookupSids3 r;
840 struct lsa_TransNameArray2 names;
841 struct lsa_RefDomainList *domains = NULL;
842 uint32_t count = sids->num_sids;
844 torture_comment(tctx, "\nTesting LookupSids3\n");
853 r.in.lookup_options = 0;
854 r.in.client_revision = 0;
855 r.out.domains = &domains;
856 r.out.count = &count;
857 r.out.names = &names;
859 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_LookupSids3_r(b, tctx, &r),
860 "LookupSids3 failed");
862 if (!NT_STATUS_IS_OK(r.out.result)) {
863 if (NT_STATUS_EQUAL(r.out.result, NT_STATUS_NONE_MAPPED)) {
864 torture_comment(tctx,
865 "LookupSids3 failed: %s - not considered as an error",
866 nt_errstr(r.out.result));
871 torture_assert_ntstatus_ok(tctx,
873 "LookupSids3 failed");
878 torture_comment(tctx, "\n");
880 if (!test_LookupNames4(b, tctx, &names, true)) {
887 static bool test_LookupSids3_fail(struct dcerpc_binding_handle *b,
888 struct torture_context *tctx,
889 struct lsa_SidArray *sids)
891 struct lsa_LookupSids3 r;
892 struct lsa_TransNameArray2 names;
893 struct lsa_RefDomainList *domains = NULL;
894 uint32_t count = sids->num_sids;
897 torture_comment(tctx, "\nTesting LookupSids3\n");
906 r.in.lookup_options = 0;
907 r.in.client_revision = 0;
908 r.out.domains = &domains;
909 r.out.count = &count;
910 r.out.names = &names;
912 status = dcerpc_lsa_LookupSids3_r(b, tctx, &r);
913 if (!NT_STATUS_IS_OK(status)) {
914 if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) {
915 torture_comment(tctx,
916 "LookupSids3 correctly returned with "
922 torture_assert_ntstatus_equal(tctx,
924 NT_STATUS_ACCESS_DENIED,
925 "LookupSids3 return value should "
930 if (NT_STATUS_EQUAL(r.out.result, NT_STATUS_ACCESS_DENIED) ||
931 NT_STATUS_EQUAL(r.out.result, NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED)) {
932 torture_comment(tctx,
933 "LookupNames4 correctly returned with "
935 nt_errstr(r.out.result));
940 "LookupSids3 return value should be "
941 "ACCESS_DENIED or RPC_PROTSEQ_NOT_SUPPORTED");
946 bool test_many_LookupSids(struct dcerpc_pipe *p,
947 struct torture_context *tctx,
948 struct policy_handle *handle)
951 struct lsa_SidArray sids;
953 struct dcerpc_binding_handle *b = p->binding_handle;
955 torture_comment(tctx, "\nTesting LookupSids with lots of SIDs\n");
959 sids.sids = talloc_array(tctx, struct lsa_SidPtr, sids.num_sids);
961 for (i=0; i<sids.num_sids; i++) {
962 const char *sidstr = "S-1-5-32-545";
963 sids.sids[i].sid = dom_sid_parse_talloc(tctx, sidstr);
966 count = sids.num_sids;
969 struct lsa_LookupSids r;
970 struct lsa_TransNameArray names;
971 struct lsa_RefDomainList *domains = NULL;
975 r.in.handle = handle;
979 r.in.count = &names.count;
980 r.out.count = &count;
981 r.out.names = &names;
982 r.out.domains = &domains;
984 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_LookupSids_r(b, tctx, &r),
985 "LookupSids failed");
986 if (!NT_STATUS_IS_OK(r.out.result)) {
987 torture_comment(tctx, "LookupSids failed - %s\n",
988 nt_errstr(r.out.result));
992 torture_comment(tctx, "\n");
994 if (!test_LookupNames(b, tctx, handle, &names)) {
999 if (p->binding->transport == NCACN_NP) {
1000 if (!test_LookupSids3_fail(b, tctx, &sids)) {
1003 if (!test_LookupNames4_fail(b, tctx)) {
1006 } else if (p->binding->transport == NCACN_IP_TCP) {
1007 struct lsa_TransNameArray2 names;
1012 if (p->conn->security_state.auth_info->auth_type == DCERPC_AUTH_TYPE_SCHANNEL &&
1013 p->conn->security_state.auth_info->auth_level >= DCERPC_AUTH_LEVEL_INTEGRITY) {
1014 if (!test_LookupSids3(b, tctx, &sids)) {
1017 if (!test_LookupNames4(b, tctx, &names, true)) {
1022 * If we don't have a secure channel these tests must
1023 * fail with ACCESS_DENIED.
1025 if (!test_LookupSids3_fail(b, tctx, &sids)) {
1028 if (!test_LookupNames4_fail(b, tctx)) {
1034 torture_comment(tctx, "\n");
1041 static void lookupsids_cb(struct tevent_req *subreq)
1043 int *replies = (int *)tevent_req_callback_data_void(subreq);
1046 status = dcerpc_lsa_LookupSids_r_recv(subreq, subreq);
1047 TALLOC_FREE(subreq);
1048 if (!NT_STATUS_IS_OK(status)) {
1049 printf("lookupsids returned %s\n", nt_errstr(status));
1053 if (*replies >= 0) {
1058 static bool test_LookupSids_async(struct dcerpc_binding_handle *b,
1059 struct torture_context *tctx,
1060 struct policy_handle *handle)
1062 struct lsa_SidArray sids;
1063 struct lsa_SidPtr sidptr;
1065 struct lsa_TransNameArray *names;
1066 struct lsa_LookupSids *r;
1067 struct lsa_RefDomainList *domains = NULL;
1068 struct tevent_req **req;
1071 const int num_async_requests = 50;
1073 count = talloc_array(tctx, uint32_t, num_async_requests);
1074 names = talloc_array(tctx, struct lsa_TransNameArray, num_async_requests);
1075 r = talloc_array(tctx, struct lsa_LookupSids, num_async_requests);
1077 torture_comment(tctx, "\nTesting %d async lookupsids request\n", num_async_requests);
1079 req = talloc_array(tctx, struct tevent_req *, num_async_requests);
1082 sids.sids = &sidptr;
1083 sidptr.sid = dom_sid_parse_talloc(tctx, "S-1-5-32-545");
1087 for (i=0; i<num_async_requests; i++) {
1090 names[i].names = NULL;
1092 r[i].in.handle = handle;
1093 r[i].in.sids = &sids;
1094 r[i].in.names = &names[i];
1096 r[i].in.count = &names[i].count;
1097 r[i].out.count = &count[i];
1098 r[i].out.names = &names[i];
1099 r[i].out.domains = &domains;
1101 req[i] = dcerpc_lsa_LookupSids_r_send(tctx, tctx->ev, b, &r[i]);
1102 if (req[i] == NULL) {
1107 tevent_req_set_callback(req[i], lookupsids_cb, &replies);
1110 while (replies >= 0 && replies < num_async_requests) {
1111 tevent_loop_once(tctx->ev);
1123 static bool test_LookupPrivValue(struct dcerpc_binding_handle *b,
1124 struct torture_context *tctx,
1125 struct policy_handle *handle,
1126 struct lsa_String *name)
1128 struct lsa_LookupPrivValue r;
1129 struct lsa_LUID luid;
1131 r.in.handle = handle;
1135 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_LookupPrivValue_r(b, tctx, &r),
1136 "LookupPrivValue failed");
1137 torture_assert_ntstatus_ok(tctx, r.out.result,
1138 "LookupPrivValue failed");
1143 static bool test_LookupPrivName(struct dcerpc_binding_handle *b,
1144 struct torture_context *tctx,
1145 struct policy_handle *handle,
1146 struct lsa_LUID *luid)
1148 struct lsa_LookupPrivName r;
1149 struct lsa_StringLarge *name = NULL;
1151 r.in.handle = handle;
1155 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_LookupPrivName_r(b, tctx, &r),
1156 "LookupPrivName failed");
1157 torture_assert_ntstatus_ok(tctx, r.out.result, "LookupPrivName failed");
1162 static bool test_RemovePrivilegesFromAccount(struct dcerpc_binding_handle *b,
1163 struct torture_context *tctx,
1164 struct policy_handle *handle,
1165 struct policy_handle *acct_handle,
1166 struct lsa_LUID *luid)
1168 struct lsa_RemovePrivilegesFromAccount r;
1169 struct lsa_PrivilegeSet privs;
1172 torture_comment(tctx, "\nTesting RemovePrivilegesFromAccount\n");
1174 r.in.handle = acct_handle;
1175 r.in.remove_all = 0;
1176 r.in.privs = &privs;
1180 privs.set = talloc_array(tctx, struct lsa_LUIDAttribute, 1);
1181 privs.set[0].luid = *luid;
1182 privs.set[0].attribute = 0;
1184 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_RemovePrivilegesFromAccount_r(b, tctx, &r),
1185 "RemovePrivilegesFromAccount failed");
1186 if (!NT_STATUS_IS_OK(r.out.result)) {
1188 struct lsa_LookupPrivName r_name;
1189 struct lsa_StringLarge *name = NULL;
1191 r_name.in.handle = handle;
1192 r_name.in.luid = luid;
1193 r_name.out.name = &name;
1195 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_LookupPrivName_r(b, tctx, &r_name),
1196 "LookupPrivName failed");
1197 if (!NT_STATUS_IS_OK(r_name.out.result)) {
1198 torture_comment(tctx, "\nLookupPrivName failed - %s\n",
1199 nt_errstr(r_name.out.result));
1202 /* Windows 2008 does not allow this to be removed */
1203 if (strcmp("SeAuditPrivilege", name->string) == 0) {
1207 torture_comment(tctx, "RemovePrivilegesFromAccount failed to remove %s - %s\n",
1209 nt_errstr(r.out.result));
1216 static bool test_AddPrivilegesToAccount(struct dcerpc_binding_handle *b,
1217 struct torture_context *tctx,
1218 struct policy_handle *acct_handle,
1219 struct lsa_LUID *luid)
1221 struct lsa_AddPrivilegesToAccount r;
1222 struct lsa_PrivilegeSet privs;
1225 torture_comment(tctx, "\nTesting AddPrivilegesToAccount\n");
1227 r.in.handle = acct_handle;
1228 r.in.privs = &privs;
1232 privs.set = talloc_array(tctx, struct lsa_LUIDAttribute, 1);
1233 privs.set[0].luid = *luid;
1234 privs.set[0].attribute = 0;
1236 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_AddPrivilegesToAccount_r(b, tctx, &r),
1237 "AddPrivilegesToAccount failed");
1238 torture_assert_ntstatus_ok(tctx, r.out.result,
1239 "AddPrivilegesToAccount failed");
1243 static bool test_EnumPrivsAccount(struct dcerpc_binding_handle *b,
1244 struct torture_context *tctx,
1245 struct policy_handle *handle,
1246 struct policy_handle *acct_handle)
1248 struct lsa_EnumPrivsAccount r;
1249 struct lsa_PrivilegeSet *privs = NULL;
1252 torture_comment(tctx, "\nTesting EnumPrivsAccount\n");
1254 r.in.handle = acct_handle;
1255 r.out.privs = &privs;
1257 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_EnumPrivsAccount_r(b, tctx, &r),
1258 "EnumPrivsAccount failed");
1259 torture_assert_ntstatus_ok(tctx, r.out.result,
1260 "EnumPrivsAccount failed");
1262 if (privs && privs->count > 0) {
1264 for (i=0;i<privs->count;i++) {
1265 test_LookupPrivName(b, tctx, handle,
1266 &privs->set[i].luid);
1269 ret &= test_RemovePrivilegesFromAccount(b, tctx, handle, acct_handle,
1270 &privs->set[0].luid);
1271 ret &= test_AddPrivilegesToAccount(b, tctx, acct_handle,
1272 &privs->set[0].luid);
1278 static bool test_GetSystemAccessAccount(struct dcerpc_binding_handle *b,
1279 struct torture_context *tctx,
1280 struct policy_handle *handle,
1281 struct policy_handle *acct_handle)
1283 uint32_t access_mask;
1284 struct lsa_GetSystemAccessAccount r;
1286 torture_comment(tctx, "\nTesting GetSystemAccessAccount\n");
1288 r.in.handle = acct_handle;
1289 r.out.access_mask = &access_mask;
1291 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_GetSystemAccessAccount_r(b, tctx, &r),
1292 "GetSystemAccessAccount failed");
1293 torture_assert_ntstatus_ok(tctx, r.out.result,
1294 "GetSystemAccessAccount failed");
1296 if (r.out.access_mask != NULL) {
1297 torture_comment(tctx, "Rights:");
1298 if (*(r.out.access_mask) & LSA_POLICY_MODE_INTERACTIVE)
1299 torture_comment(tctx, " LSA_POLICY_MODE_INTERACTIVE");
1300 if (*(r.out.access_mask) & LSA_POLICY_MODE_NETWORK)
1301 torture_comment(tctx, " LSA_POLICY_MODE_NETWORK");
1302 if (*(r.out.access_mask) & LSA_POLICY_MODE_BATCH)
1303 torture_comment(tctx, " LSA_POLICY_MODE_BATCH");
1304 if (*(r.out.access_mask) & LSA_POLICY_MODE_SERVICE)
1305 torture_comment(tctx, " LSA_POLICY_MODE_SERVICE");
1306 if (*(r.out.access_mask) & LSA_POLICY_MODE_PROXY)
1307 torture_comment(tctx, " LSA_POLICY_MODE_PROXY");
1308 if (*(r.out.access_mask) & LSA_POLICY_MODE_DENY_INTERACTIVE)
1309 torture_comment(tctx, " LSA_POLICY_MODE_DENY_INTERACTIVE");
1310 if (*(r.out.access_mask) & LSA_POLICY_MODE_DENY_NETWORK)
1311 torture_comment(tctx, " LSA_POLICY_MODE_DENY_NETWORK");
1312 if (*(r.out.access_mask) & LSA_POLICY_MODE_DENY_BATCH)
1313 torture_comment(tctx, " LSA_POLICY_MODE_DENY_BATCH");
1314 if (*(r.out.access_mask) & LSA_POLICY_MODE_DENY_SERVICE)
1315 torture_comment(tctx, " LSA_POLICY_MODE_DENY_SERVICE");
1316 if (*(r.out.access_mask) & LSA_POLICY_MODE_REMOTE_INTERACTIVE)
1317 torture_comment(tctx, " LSA_POLICY_MODE_REMOTE_INTERACTIVE");
1318 if (*(r.out.access_mask) & LSA_POLICY_MODE_DENY_REMOTE_INTERACTIVE)
1319 torture_comment(tctx, " LSA_POLICY_MODE_DENY_REMOTE_INTERACTIVE");
1320 if (*(r.out.access_mask) & LSA_POLICY_MODE_ALL)
1321 torture_comment(tctx, " LSA_POLICY_MODE_ALL");
1322 if (*(r.out.access_mask) & LSA_POLICY_MODE_ALL_NT4)
1323 torture_comment(tctx, " LSA_POLICY_MODE_ALL_NT4");
1324 torture_comment(tctx, "\n");
1330 static bool test_Delete(struct dcerpc_binding_handle *b,
1331 struct torture_context *tctx,
1332 struct policy_handle *handle)
1334 struct lsa_Delete r;
1336 torture_comment(tctx, "\nTesting Delete\n");
1338 r.in.handle = handle;
1339 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_Delete_r(b, tctx, &r),
1341 if (!NT_STATUS_EQUAL(r.out.result, NT_STATUS_NOT_SUPPORTED)) {
1342 torture_comment(tctx, "Delete should have failed NT_STATUS_NOT_SUPPORTED - %s\n", nt_errstr(r.out.result));
1349 static bool test_DeleteObject(struct dcerpc_binding_handle *b,
1350 struct torture_context *tctx,
1351 struct policy_handle *handle)
1353 struct lsa_DeleteObject r;
1355 torture_comment(tctx, "\nTesting DeleteObject\n");
1357 r.in.handle = handle;
1358 r.out.handle = handle;
1359 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_DeleteObject_r(b, tctx, &r),
1360 "DeleteObject failed");
1361 torture_assert_ntstatus_ok(tctx, r.out.result,
1362 "DeleteObject failed");
1368 static bool test_CreateAccount(struct dcerpc_binding_handle *b,
1369 struct torture_context *tctx,
1370 struct policy_handle *handle)
1372 struct lsa_CreateAccount r;
1373 struct dom_sid2 *newsid;
1374 struct policy_handle acct_handle;
1376 newsid = dom_sid_parse_talloc(tctx, "S-1-5-12349876-4321-2854");
1378 torture_comment(tctx, "\nTesting CreateAccount\n");
1380 r.in.handle = handle;
1382 r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
1383 r.out.acct_handle = &acct_handle;
1385 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_CreateAccount_r(b, tctx, &r),
1386 "CreateAccount failed");
1387 if (NT_STATUS_EQUAL(r.out.result, NT_STATUS_OBJECT_NAME_COLLISION)) {
1388 struct lsa_OpenAccount r_o;
1389 r_o.in.handle = handle;
1390 r_o.in.sid = newsid;
1391 r_o.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
1392 r_o.out.acct_handle = &acct_handle;
1394 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_OpenAccount_r(b, tctx, &r_o),
1395 "OpenAccount failed");
1396 torture_assert_ntstatus_ok(tctx, r_o.out.result,
1397 "OpenAccount failed");
1399 torture_assert_ntstatus_ok(tctx, r.out.result,
1400 "CreateAccount failed");
1403 if (!test_Delete(b, tctx, &acct_handle)) {
1407 if (!test_DeleteObject(b, tctx, &acct_handle)) {
1414 static bool test_DeleteTrustedDomain(struct dcerpc_binding_handle *b,
1415 struct torture_context *tctx,
1416 struct policy_handle *handle,
1417 struct lsa_StringLarge name)
1419 struct lsa_OpenTrustedDomainByName r;
1420 struct policy_handle trustdom_handle;
1422 r.in.handle = handle;
1423 r.in.name.string = name.string;
1424 r.in.access_mask = SEC_STD_DELETE;
1425 r.out.trustdom_handle = &trustdom_handle;
1427 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_OpenTrustedDomainByName_r(b, tctx, &r),
1428 "OpenTrustedDomainByName failed");
1429 torture_assert_ntstatus_ok(tctx, r.out.result,
1430 "OpenTrustedDomainByName failed");
1432 if (!test_Delete(b, tctx, &trustdom_handle)) {
1436 if (!test_DeleteObject(b, tctx, &trustdom_handle)) {
1443 static bool test_DeleteTrustedDomainBySid(struct dcerpc_binding_handle *b,
1444 struct torture_context *tctx,
1445 struct policy_handle *handle,
1446 struct dom_sid *sid)
1448 struct lsa_DeleteTrustedDomain r;
1450 r.in.handle = handle;
1453 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_DeleteTrustedDomain_r(b, tctx, &r),
1454 "DeleteTrustedDomain failed");
1455 torture_assert_ntstatus_ok(tctx, r.out.result,
1456 "DeleteTrustedDomain failed");
1462 static bool test_CreateSecret(struct dcerpc_pipe *p,
1463 struct torture_context *tctx,
1464 struct policy_handle *handle)
1466 struct lsa_CreateSecret r;
1467 struct lsa_OpenSecret r2;
1468 struct lsa_SetSecret r3;
1469 struct lsa_QuerySecret r4;
1470 struct lsa_SetSecret r5;
1471 struct lsa_QuerySecret r6;
1472 struct lsa_SetSecret r7;
1473 struct lsa_QuerySecret r8;
1474 struct policy_handle sec_handle, sec_handle2, sec_handle3;
1475 struct lsa_DeleteObject d_o;
1476 struct lsa_DATA_BUF buf1;
1477 struct lsa_DATA_BUF_PTR bufp1;
1478 struct lsa_DATA_BUF_PTR bufp2;
1481 DATA_BLOB session_key;
1482 NTTIME old_mtime, new_mtime;
1484 const char *secret1 = "abcdef12345699qwerty";
1486 const char *secret3 = "ABCDEF12345699QWERTY";
1488 const char *secret5 = "NEW-SAMBA4-SECRET";
1492 const int LOCAL = 0;
1493 const int GLOBAL = 1;
1494 struct dcerpc_binding_handle *b = p->binding_handle;
1496 secname[LOCAL] = talloc_asprintf(tctx, "torturesecret-%u", (unsigned int)random());
1497 secname[GLOBAL] = talloc_asprintf(tctx, "G$torturesecret-%u", (unsigned int)random());
1499 for (i=0; i< 2; i++) {
1500 torture_comment(tctx, "\nTesting CreateSecret of %s\n", secname[i]);
1502 init_lsa_String(&r.in.name, secname[i]);
1504 r.in.handle = handle;
1505 r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
1506 r.out.sec_handle = &sec_handle;
1508 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_CreateSecret_r(b, tctx, &r),
1509 "CreateSecret failed");
1510 torture_assert_ntstatus_ok(tctx, r.out.result,
1511 "CreateSecret failed");
1513 r.in.handle = handle;
1514 r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
1515 r.out.sec_handle = &sec_handle3;
1517 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_CreateSecret_r(b, tctx, &r),
1518 "CreateSecret failed");
1519 torture_assert_ntstatus_equal(tctx, r.out.result, NT_STATUS_OBJECT_NAME_COLLISION,
1520 "CreateSecret should have failed OBJECT_NAME_COLLISION");
1522 r2.in.handle = handle;
1523 r2.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
1524 r2.in.name = r.in.name;
1525 r2.out.sec_handle = &sec_handle2;
1527 torture_comment(tctx, "Testing OpenSecret\n");
1529 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_OpenSecret_r(b, tctx, &r2),
1530 "OpenSecret failed");
1531 torture_assert_ntstatus_ok(tctx, r2.out.result,
1532 "OpenSecret failed");
1534 torture_assert_ntstatus_ok(tctx, dcerpc_fetch_session_key(p, &session_key),
1535 "dcerpc_fetch_session_key failed");
1537 enc_key = sess_encrypt_string(secret1, &session_key);
1539 r3.in.sec_handle = &sec_handle;
1540 r3.in.new_val = &buf1;
1541 r3.in.old_val = NULL;
1542 r3.in.new_val->data = enc_key.data;
1543 r3.in.new_val->length = enc_key.length;
1544 r3.in.new_val->size = enc_key.length;
1546 torture_comment(tctx, "Testing SetSecret\n");
1548 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_SetSecret_r(b, tctx, &r3),
1549 "SetSecret failed");
1550 torture_assert_ntstatus_ok(tctx, r3.out.result,
1551 "SetSecret failed");
1553 r3.in.sec_handle = &sec_handle;
1554 r3.in.new_val = &buf1;
1555 r3.in.old_val = NULL;
1556 r3.in.new_val->data = enc_key.data;
1557 r3.in.new_val->length = enc_key.length;
1558 r3.in.new_val->size = enc_key.length;
1560 /* break the encrypted data */
1563 torture_comment(tctx, "Testing SetSecret with broken key\n");
1565 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_SetSecret_r(b, tctx, &r3),
1566 "SetSecret failed");
1567 torture_assert_ntstatus_equal(tctx, r3.out.result, NT_STATUS_UNKNOWN_REVISION,
1568 "SetSecret should have failed UNKNOWN_REVISION");
1570 data_blob_free(&enc_key);
1572 ZERO_STRUCT(new_mtime);
1573 ZERO_STRUCT(old_mtime);
1575 /* fetch the secret back again */
1576 r4.in.sec_handle = &sec_handle;
1577 r4.in.new_val = &bufp1;
1578 r4.in.new_mtime = &new_mtime;
1579 r4.in.old_val = NULL;
1580 r4.in.old_mtime = NULL;
1584 torture_comment(tctx, "Testing QuerySecret\n");
1585 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_QuerySecret_r(b, tctx, &r4),
1586 "QuerySecret failed");
1587 if (!NT_STATUS_IS_OK(r4.out.result)) {
1588 torture_comment(tctx, "QuerySecret failed - %s\n", nt_errstr(r4.out.result));
1591 if (r4.out.new_val == NULL || r4.out.new_val->buf == NULL) {
1592 torture_comment(tctx, "No secret buffer returned\n");
1595 blob1.data = r4.out.new_val->buf->data;
1596 blob1.length = r4.out.new_val->buf->size;
1598 secret2 = sess_decrypt_string(tctx,
1599 &blob1, &session_key);
1601 if (strcmp(secret1, secret2) != 0) {
1602 torture_comment(tctx, "Returned secret (r4) '%s' doesn't match '%s'\n",
1609 enc_key = sess_encrypt_string(secret3, &session_key);
1611 r5.in.sec_handle = &sec_handle;
1612 r5.in.new_val = &buf1;
1613 r5.in.old_val = NULL;
1614 r5.in.new_val->data = enc_key.data;
1615 r5.in.new_val->length = enc_key.length;
1616 r5.in.new_val->size = enc_key.length;
1620 torture_comment(tctx, "Testing SetSecret (existing value should move to old)\n");
1622 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_SetSecret_r(b, tctx, &r5),
1623 "SetSecret failed");
1624 if (!NT_STATUS_IS_OK(r5.out.result)) {
1625 torture_comment(tctx, "SetSecret failed - %s\n", nt_errstr(r5.out.result));
1629 data_blob_free(&enc_key);
1631 ZERO_STRUCT(new_mtime);
1632 ZERO_STRUCT(old_mtime);
1634 /* fetch the secret back again */
1635 r6.in.sec_handle = &sec_handle;
1636 r6.in.new_val = &bufp1;
1637 r6.in.new_mtime = &new_mtime;
1638 r6.in.old_val = &bufp2;
1639 r6.in.old_mtime = &old_mtime;
1644 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_QuerySecret_r(b, tctx, &r6),
1645 "QuerySecret failed");
1646 if (!NT_STATUS_IS_OK(r6.out.result)) {
1647 torture_comment(tctx, "QuerySecret failed - %s\n", nt_errstr(r6.out.result));
1652 if (r6.out.new_val->buf == NULL || r6.out.old_val->buf == NULL
1653 || r6.out.new_mtime == NULL || r6.out.old_mtime == NULL) {
1654 torture_comment(tctx, "Both secret buffers and both times not returned\n");
1658 blob1.data = r6.out.new_val->buf->data;
1659 blob1.length = r6.out.new_val->buf->size;
1661 secret4 = sess_decrypt_string(tctx,
1662 &blob1, &session_key);
1664 if (strcmp(secret3, secret4) != 0) {
1665 torture_comment(tctx, "Returned NEW secret %s doesn't match %s\n", secret4, secret3);
1669 blob1.data = r6.out.old_val->buf->data;
1670 blob1.length = r6.out.old_val->buf->length;
1672 secret2 = sess_decrypt_string(tctx,
1673 &blob1, &session_key);
1675 if (strcmp(secret1, secret2) != 0) {
1676 torture_comment(tctx, "Returned OLD secret %s doesn't match %s\n", secret2, secret1);
1680 if (*r6.out.new_mtime == *r6.out.old_mtime) {
1681 torture_comment(tctx, "Returned secret (r6-%d) %s must not have same mtime for both secrets: %s != %s\n",
1684 nt_time_string(tctx, *r6.out.old_mtime),
1685 nt_time_string(tctx, *r6.out.new_mtime));
1691 enc_key = sess_encrypt_string(secret5, &session_key);
1693 r7.in.sec_handle = &sec_handle;
1694 r7.in.old_val = &buf1;
1695 r7.in.old_val->data = enc_key.data;
1696 r7.in.old_val->length = enc_key.length;
1697 r7.in.old_val->size = enc_key.length;
1698 r7.in.new_val = NULL;
1700 torture_comment(tctx, "Testing SetSecret of old Secret only\n");
1702 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_SetSecret_r(b, tctx, &r7),
1703 "SetSecret failed");
1704 if (!NT_STATUS_IS_OK(r7.out.result)) {
1705 torture_comment(tctx, "SetSecret failed - %s\n", nt_errstr(r7.out.result));
1709 data_blob_free(&enc_key);
1711 /* fetch the secret back again */
1712 r8.in.sec_handle = &sec_handle;
1713 r8.in.new_val = &bufp1;
1714 r8.in.new_mtime = &new_mtime;
1715 r8.in.old_val = &bufp2;
1716 r8.in.old_mtime = &old_mtime;
1721 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_QuerySecret_r(b, tctx, &r8),
1722 "QuerySecret failed");
1723 if (!NT_STATUS_IS_OK(r8.out.result)) {
1724 torture_comment(tctx, "QuerySecret failed - %s\n", nt_errstr(r8.out.result));
1727 if (!r8.out.new_val || !r8.out.old_val) {
1728 torture_comment(tctx, "in/out pointers not returned, despite being set on in for QuerySecret\n");
1730 } else if (r8.out.new_val->buf != NULL) {
1731 torture_comment(tctx, "NEW secret buffer must not be returned after OLD set\n");
1733 } else if (r8.out.old_val->buf == NULL) {
1734 torture_comment(tctx, "OLD secret buffer was not returned after OLD set\n");
1736 } else if (r8.out.new_mtime == NULL || r8.out.old_mtime == NULL) {
1737 torture_comment(tctx, "Both times not returned after OLD set\n");
1740 blob1.data = r8.out.old_val->buf->data;
1741 blob1.length = r8.out.old_val->buf->size;
1743 secret6 = sess_decrypt_string(tctx,
1744 &blob1, &session_key);
1746 if (strcmp(secret5, secret6) != 0) {
1747 torture_comment(tctx, "Returned OLD secret %s doesn't match %s\n", secret5, secret6);
1751 if (*r8.out.new_mtime != *r8.out.old_mtime) {
1752 torture_comment(tctx, "Returned secret (r8) %s did not had same mtime for both secrets: %s != %s\n",
1754 nt_time_string(tctx, *r8.out.old_mtime),
1755 nt_time_string(tctx, *r8.out.new_mtime));
1761 if (!test_Delete(b, tctx, &sec_handle)) {
1765 if (!test_DeleteObject(b, tctx, &sec_handle)) {
1769 d_o.in.handle = &sec_handle2;
1770 d_o.out.handle = &sec_handle2;
1771 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_DeleteObject_r(b, tctx, &d_o),
1772 "DeleteObject failed");
1773 torture_assert_ntstatus_equal(tctx, d_o.out.result, NT_STATUS_INVALID_HANDLE,
1774 "OpenSecret expected INVALID_HANDLE");
1776 torture_comment(tctx, "Testing OpenSecret of just-deleted secret\n");
1778 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_OpenSecret_r(b, tctx, &r2),
1779 "OpenSecret failed");
1780 torture_assert_ntstatus_equal(tctx, r2.out.result, NT_STATUS_OBJECT_NAME_NOT_FOUND,
1781 "OpenSecret expected OBJECT_NAME_NOT_FOUND");
1787 static bool test_EnumAccountRights(struct dcerpc_binding_handle *b,
1788 struct torture_context *tctx,
1789 struct policy_handle *acct_handle,
1790 struct dom_sid *sid)
1792 struct lsa_EnumAccountRights r;
1793 struct lsa_RightSet rights;
1795 torture_comment(tctx, "\nTesting EnumAccountRights\n");
1797 r.in.handle = acct_handle;
1799 r.out.rights = &rights;
1801 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_EnumAccountRights_r(b, tctx, &r),
1802 "EnumAccountRights failed");
1803 if (!NT_STATUS_IS_OK(r.out.result)) {
1804 torture_comment(tctx, "EnumAccountRights of %s failed - %s\n",
1805 dom_sid_string(tctx, sid), nt_errstr(r.out.result));
1807 torture_assert_ntstatus_ok(tctx, r.out.result,
1808 "EnumAccountRights failed");
1814 static bool test_QuerySecurity(struct dcerpc_binding_handle *b,
1815 struct torture_context *tctx,
1816 struct policy_handle *handle,
1817 struct policy_handle *acct_handle)
1819 struct lsa_QuerySecurity r;
1820 struct sec_desc_buf *sdbuf = NULL;
1822 if (torture_setting_bool(tctx, "samba4", false)) {
1823 torture_comment(tctx, "\nskipping QuerySecurity test against Samba4\n");
1827 torture_comment(tctx, "\nTesting QuerySecurity\n");
1829 r.in.handle = acct_handle;
1830 r.in.sec_info = SECINFO_OWNER |
1833 r.out.sdbuf = &sdbuf;
1835 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_QuerySecurity_r(b, tctx, &r),
1836 "QuerySecurity failed");
1837 if (!NT_STATUS_IS_OK(r.out.result)) {
1838 torture_comment(tctx, "QuerySecurity failed - %s\n", nt_errstr(r.out.result));
1845 static bool test_OpenAccount(struct dcerpc_binding_handle *b,
1846 struct torture_context *tctx,
1847 struct policy_handle *handle,
1848 struct dom_sid *sid)
1850 struct lsa_OpenAccount r;
1851 struct policy_handle acct_handle;
1853 torture_comment(tctx, "\nTesting OpenAccount\n");
1855 r.in.handle = handle;
1857 r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
1858 r.out.acct_handle = &acct_handle;
1860 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_OpenAccount_r(b, tctx, &r),
1861 "OpenAccount failed");
1862 torture_assert_ntstatus_ok(tctx, r.out.result,
1863 "OpenAccount failed");
1865 if (!test_EnumPrivsAccount(b, tctx, handle, &acct_handle)) {
1869 if (!test_GetSystemAccessAccount(b, tctx, handle, &acct_handle)) {
1873 if (!test_QuerySecurity(b, tctx, handle, &acct_handle)) {
1880 static bool test_EnumAccounts(struct dcerpc_binding_handle *b,
1881 struct torture_context *tctx,
1882 struct policy_handle *handle)
1884 struct lsa_EnumAccounts r;
1885 struct lsa_SidArray sids1, sids2;
1886 uint32_t resume_handle = 0;
1890 torture_comment(tctx, "\nTesting EnumAccounts\n");
1892 r.in.handle = handle;
1893 r.in.resume_handle = &resume_handle;
1894 r.in.num_entries = 100;
1895 r.out.resume_handle = &resume_handle;
1896 r.out.sids = &sids1;
1900 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_EnumAccounts_r(b, tctx, &r),
1901 "EnumAccounts failed");
1902 if (NT_STATUS_EQUAL(r.out.result, NT_STATUS_NO_MORE_ENTRIES)) {
1905 torture_assert_ntstatus_ok(tctx, r.out.result,
1906 "EnumAccounts failed");
1908 if (!test_LookupSids(b, tctx, handle, &sids1)) {
1912 if (!test_LookupSids2(b, tctx, handle, &sids1)) {
1916 /* Can't test lookupSids3 here, as clearly we must not
1917 * be on schannel, or we would not be able to do the
1920 torture_comment(tctx, "Testing all accounts\n");
1921 for (i=0;i<sids1.num_sids;i++) {
1922 ret &= test_OpenAccount(b, tctx, handle, sids1.sids[i].sid);
1923 ret &= test_EnumAccountRights(b, tctx, handle, sids1.sids[i].sid);
1925 torture_comment(tctx, "\n");
1928 if (sids1.num_sids < 3) {
1932 torture_comment(tctx, "Trying EnumAccounts partial listing (asking for 1 at 2)\n");
1934 r.in.num_entries = 1;
1935 r.out.sids = &sids2;
1937 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_EnumAccounts_r(b, tctx, &r),
1938 "EnumAccounts failed");
1939 torture_assert_ntstatus_ok(tctx, r.out.result,
1940 "EnumAccounts failed");
1942 if (sids2.num_sids != 1) {
1943 torture_comment(tctx, "Returned wrong number of entries (%d)\n", sids2.num_sids);
1950 static bool test_LookupPrivDisplayName(struct dcerpc_binding_handle *b,
1951 struct torture_context *tctx,
1952 struct policy_handle *handle,
1953 struct lsa_String *priv_name)
1955 struct lsa_LookupPrivDisplayName r;
1956 /* produce a reasonable range of language output without screwing up
1958 uint16_t language_id = (random() % 4) + 0x409;
1959 uint16_t returned_language_id = 0;
1960 struct lsa_StringLarge *disp_name = NULL;
1962 torture_comment(tctx, "\nTesting LookupPrivDisplayName(%s)\n", priv_name->string);
1964 r.in.handle = handle;
1965 r.in.name = priv_name;
1966 r.in.language_id = language_id;
1967 r.in.language_id_sys = 0;
1968 r.out.returned_language_id = &returned_language_id;
1969 r.out.disp_name = &disp_name;
1971 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_LookupPrivDisplayName_r(b, tctx, &r),
1972 "LookupPrivDisplayName failed");
1973 if (!NT_STATUS_IS_OK(r.out.result)) {
1974 torture_comment(tctx, "LookupPrivDisplayName failed - %s\n", nt_errstr(r.out.result));
1977 torture_comment(tctx, "%s -> \"%s\" (language 0x%x/0x%x)\n",
1978 priv_name->string, disp_name->string,
1979 r.in.language_id, *r.out.returned_language_id);
1984 static bool test_EnumAccountsWithUserRight(struct dcerpc_binding_handle *b,
1985 struct torture_context *tctx,
1986 struct policy_handle *handle,
1987 struct lsa_String *priv_name)
1989 struct lsa_EnumAccountsWithUserRight r;
1990 struct lsa_SidArray sids;
1994 torture_comment(tctx, "\nTesting EnumAccountsWithUserRight(%s)\n", priv_name->string);
1996 r.in.handle = handle;
1997 r.in.name = priv_name;
2000 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_EnumAccountsWithUserRight_r(b, tctx, &r),
2001 "EnumAccountsWithUserRight failed");
2003 /* NT_STATUS_NO_MORE_ENTRIES means noone has this privilege */
2004 if (NT_STATUS_EQUAL(r.out.result, NT_STATUS_NO_MORE_ENTRIES)) {
2008 if (!NT_STATUS_IS_OK(r.out.result)) {
2009 torture_comment(tctx, "EnumAccountsWithUserRight failed - %s\n", nt_errstr(r.out.result));
2017 static bool test_EnumPrivs(struct dcerpc_binding_handle *b,
2018 struct torture_context *tctx,
2019 struct policy_handle *handle)
2021 struct lsa_EnumPrivs r;
2022 struct lsa_PrivArray privs1;
2023 uint32_t resume_handle = 0;
2027 torture_comment(tctx, "\nTesting EnumPrivs\n");
2029 r.in.handle = handle;
2030 r.in.resume_handle = &resume_handle;
2031 r.in.max_count = 100;
2032 r.out.resume_handle = &resume_handle;
2033 r.out.privs = &privs1;
2036 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_EnumPrivs_r(b, tctx, &r),
2037 "EnumPrivs failed");
2038 torture_assert_ntstatus_ok(tctx, r.out.result,
2039 "EnumPrivs failed");
2041 for (i = 0; i< privs1.count; i++) {
2042 test_LookupPrivDisplayName(b, tctx, handle, (struct lsa_String *)&privs1.privs[i].name);
2043 test_LookupPrivValue(b, tctx, handle, (struct lsa_String *)&privs1.privs[i].name);
2044 if (!test_EnumAccountsWithUserRight(b, tctx, handle, (struct lsa_String *)&privs1.privs[i].name)) {
2052 static bool test_QueryForestTrustInformation(struct dcerpc_binding_handle *b,
2053 struct torture_context *tctx,
2054 struct policy_handle *handle,
2055 const char *trusted_domain_name)
2058 struct lsa_lsaRQueryForestTrustInformation r;
2059 struct lsa_String string;
2060 struct lsa_ForestTrustInformation info, *info_ptr;
2062 torture_comment(tctx, "\nTesting lsaRQueryForestTrustInformation\n");
2064 if (torture_setting_bool(tctx, "samba4", false)) {
2065 torture_comment(tctx, "skipping QueryForestTrustInformation against Samba4\n");
2069 ZERO_STRUCT(string);
2071 if (trusted_domain_name) {
2072 init_lsa_String(&string, trusted_domain_name);
2077 r.in.handle = handle;
2078 r.in.trusted_domain_name = &string;
2080 r.out.forest_trust_info = &info_ptr;
2082 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_lsaRQueryForestTrustInformation_r(b, tctx, &r),
2083 "lsaRQueryForestTrustInformation failed");
2085 if (!NT_STATUS_IS_OK(r.out.result)) {
2086 torture_comment(tctx, "lsaRQueryForestTrustInformation of %s failed - %s\n", trusted_domain_name, nt_errstr(r.out.result));
2093 static bool test_query_each_TrustDomEx(struct dcerpc_binding_handle *b,
2094 struct torture_context *tctx,
2095 struct policy_handle *handle,
2096 struct lsa_DomainListEx *domains)
2101 for (i=0; i< domains->count; i++) {
2103 if (domains->domains[i].trust_attributes & NETR_TRUST_ATTRIBUTE_FOREST_TRANSITIVE) {
2104 ret &= test_QueryForestTrustInformation(b, tctx, handle,
2105 domains->domains[i].domain_name.string);
2112 static bool test_query_each_TrustDom(struct dcerpc_binding_handle *b,
2113 struct torture_context *tctx,
2114 struct policy_handle *handle,
2115 struct lsa_DomainList *domains)
2120 torture_comment(tctx, "\nTesting OpenTrustedDomain, OpenTrustedDomainByName and QueryInfoTrustedDomain\n");
2121 for (i=0; i< domains->count; i++) {
2122 struct lsa_OpenTrustedDomain trust;
2123 struct lsa_OpenTrustedDomainByName trust_by_name;
2124 struct policy_handle trustdom_handle;
2125 struct policy_handle handle2;
2127 struct lsa_CloseTrustedDomainEx c_trust;
2128 int levels [] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};
2129 int ok[] = {1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1};
2131 if (domains->domains[i].sid) {
2132 trust.in.handle = handle;
2133 trust.in.sid = domains->domains[i].sid;
2134 trust.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
2135 trust.out.trustdom_handle = &trustdom_handle;
2137 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_OpenTrustedDomain_r(b, tctx, &trust),
2138 "OpenTrustedDomain failed");
2140 if (!NT_STATUS_IS_OK(trust.out.result)) {
2141 torture_comment(tctx, "OpenTrustedDomain failed - %s\n", nt_errstr(trust.out.result));
2145 c.in.handle = &trustdom_handle;
2146 c.out.handle = &handle2;
2148 c_trust.in.handle = &trustdom_handle;
2149 c_trust.out.handle = &handle2;
2151 for (j=0; j < ARRAY_SIZE(levels); j++) {
2152 struct lsa_QueryTrustedDomainInfo q;
2153 union lsa_TrustedDomainInfo *info = NULL;
2154 q.in.trustdom_handle = &trustdom_handle;
2155 q.in.level = levels[j];
2157 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_QueryTrustedDomainInfo_r(b, tctx, &q),
2158 "QueryTrustedDomainInfo failed");
2159 if (!NT_STATUS_IS_OK(q.out.result) && ok[j]) {
2160 torture_comment(tctx, "QueryTrustedDomainInfo level %d failed - %s\n",
2161 levels[j], nt_errstr(q.out.result));
2163 } else if (NT_STATUS_IS_OK(q.out.result) && !ok[j]) {
2164 torture_comment(tctx, "QueryTrustedDomainInfo level %d unexpectedly succeeded - %s\n",
2165 levels[j], nt_errstr(q.out.result));
2170 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_CloseTrustedDomainEx_r(b, tctx, &c_trust),
2171 "CloseTrustedDomainEx failed");
2172 if (!NT_STATUS_EQUAL(c_trust.out.result, NT_STATUS_NOT_IMPLEMENTED)) {
2173 torture_comment(tctx, "Expected CloseTrustedDomainEx to return NT_STATUS_NOT_IMPLEMENTED, instead - %s\n", nt_errstr(c_trust.out.result));
2177 c.in.handle = &trustdom_handle;
2178 c.out.handle = &handle2;
2180 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_Close_r(b, tctx, &c),
2182 if (!NT_STATUS_IS_OK(c.out.result)) {
2183 torture_comment(tctx, "Close of trusted domain failed - %s\n", nt_errstr(c.out.result));
2187 for (j=0; j < ARRAY_SIZE(levels); j++) {
2188 struct lsa_QueryTrustedDomainInfoBySid q;
2189 union lsa_TrustedDomainInfo *info = NULL;
2191 if (!domains->domains[i].sid) {
2195 q.in.handle = handle;
2196 q.in.dom_sid = domains->domains[i].sid;
2197 q.in.level = levels[j];
2200 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_QueryTrustedDomainInfoBySid_r(b, tctx, &q),
2201 "lsa_QueryTrustedDomainInfoBySid failed");
2202 if (!NT_STATUS_IS_OK(q.out.result) && ok[j]) {
2203 torture_comment(tctx, "QueryTrustedDomainInfoBySid level %d failed - %s\n",
2204 levels[j], nt_errstr(q.out.result));
2206 } else if (NT_STATUS_IS_OK(q.out.result) && !ok[j]) {
2207 torture_comment(tctx, "QueryTrustedDomainInfoBySid level %d unexpectedly succeeded - %s\n",
2208 levels[j], nt_errstr(q.out.result));
2214 trust_by_name.in.handle = handle;
2215 trust_by_name.in.name.string = domains->domains[i].name.string;
2216 trust_by_name.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
2217 trust_by_name.out.trustdom_handle = &trustdom_handle;
2219 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_OpenTrustedDomainByName_r(b, tctx, &trust_by_name),
2220 "OpenTrustedDomainByName failed");
2222 if (!NT_STATUS_IS_OK(trust_by_name.out.result)) {
2223 torture_comment(tctx, "OpenTrustedDomainByName failed - %s\n", nt_errstr(trust_by_name.out.result));
2227 for (j=0; j < ARRAY_SIZE(levels); j++) {
2228 struct lsa_QueryTrustedDomainInfo q;
2229 union lsa_TrustedDomainInfo *info = NULL;
2230 q.in.trustdom_handle = &trustdom_handle;
2231 q.in.level = levels[j];
2233 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_QueryTrustedDomainInfo_r(b, tctx, &q),
2234 "QueryTrustedDomainInfo failed");
2235 if (!NT_STATUS_IS_OK(q.out.result) && ok[j]) {
2236 torture_comment(tctx, "QueryTrustedDomainInfo level %d failed - %s\n",
2237 levels[j], nt_errstr(q.out.result));
2239 } else if (NT_STATUS_IS_OK(q.out.result) && !ok[j]) {
2240 torture_comment(tctx, "QueryTrustedDomainInfo level %d unexpectedly succeeded - %s\n",
2241 levels[j], nt_errstr(q.out.result));
2246 c.in.handle = &trustdom_handle;
2247 c.out.handle = &handle2;
2249 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_Close_r(b, tctx, &c),
2251 if (!NT_STATUS_IS_OK(c.out.result)) {
2252 torture_comment(tctx, "Close of trusted domain failed - %s\n", nt_errstr(c.out.result));
2256 for (j=0; j < ARRAY_SIZE(levels); j++) {
2257 struct lsa_QueryTrustedDomainInfoByName q;
2258 union lsa_TrustedDomainInfo *info = NULL;
2259 struct lsa_String name;
2261 name.string = domains->domains[i].name.string;
2263 q.in.handle = handle;
2264 q.in.trusted_domain = &name;
2265 q.in.level = levels[j];
2267 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_QueryTrustedDomainInfoByName_r(b, tctx, &q),
2268 "QueryTrustedDomainInfoByName failed");
2269 if (!NT_STATUS_IS_OK(q.out.result) && ok[j]) {
2270 torture_comment(tctx, "QueryTrustedDomainInfoByName level %d failed - %s\n",
2271 levels[j], nt_errstr(q.out.result));
2273 } else if (NT_STATUS_IS_OK(q.out.result) && !ok[j]) {
2274 torture_comment(tctx, "QueryTrustedDomainInfoByName level %d unexpectedly succeeded - %s\n",
2275 levels[j], nt_errstr(q.out.result));
2283 static bool test_EnumTrustDom(struct dcerpc_binding_handle *b,
2284 struct torture_context *tctx,
2285 struct policy_handle *handle)
2287 struct lsa_EnumTrustDom r;
2288 uint32_t in_resume_handle = 0;
2289 uint32_t out_resume_handle;
2290 struct lsa_DomainList domains;
2293 torture_comment(tctx, "\nTesting EnumTrustDom\n");
2295 r.in.handle = handle;
2296 r.in.resume_handle = &in_resume_handle;
2298 r.out.domains = &domains;
2299 r.out.resume_handle = &out_resume_handle;
2301 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_EnumTrustDom_r(b, tctx, &r),
2302 "lsa_EnumTrustDom failed");
2304 /* according to MS-LSAD 3.1.4.7.8 output resume handle MUST
2305 * always be larger than the previous input resume handle, in
2306 * particular when hitting the last query it is vital to set the
2307 * resume handle correctly to avoid infinite client loops, as
2308 * seen e.g. with Windows XP SP3 when resume handle is 0 and
2309 * status is NT_STATUS_OK - gd */
2311 if (NT_STATUS_IS_OK(r.out.result) ||
2312 NT_STATUS_EQUAL(r.out.result, NT_STATUS_NO_MORE_ENTRIES) ||
2313 NT_STATUS_EQUAL(r.out.result, STATUS_MORE_ENTRIES))
2315 if (out_resume_handle <= in_resume_handle) {
2316 torture_comment(tctx, "EnumTrustDom failed - should have returned output resume_handle (0x%08x) larger than input resume handle (0x%08x)\n",
2317 out_resume_handle, in_resume_handle);
2322 if (NT_STATUS_IS_OK(r.out.result)) {
2323 if (domains.count == 0) {
2324 torture_comment(tctx, "EnumTrustDom failed - should have returned 'NT_STATUS_NO_MORE_ENTRIES' for 0 trusted domains\n");
2327 } else if (!(NT_STATUS_EQUAL(r.out.result, STATUS_MORE_ENTRIES) || NT_STATUS_EQUAL(r.out.result, NT_STATUS_NO_MORE_ENTRIES))) {
2328 torture_comment(tctx, "EnumTrustDom of zero size failed - %s\n", nt_errstr(r.out.result));
2332 /* Start from the bottom again */
2333 in_resume_handle = 0;
2336 r.in.handle = handle;
2337 r.in.resume_handle = &in_resume_handle;
2338 r.in.max_size = LSA_ENUM_TRUST_DOMAIN_MULTIPLIER * 3;
2339 r.out.domains = &domains;
2340 r.out.resume_handle = &out_resume_handle;
2342 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_EnumTrustDom_r(b, tctx, &r),
2343 "EnumTrustDom failed");
2345 /* according to MS-LSAD 3.1.4.7.8 output resume handle MUST
2346 * always be larger than the previous input resume handle, in
2347 * particular when hitting the last query it is vital to set the
2348 * resume handle correctly to avoid infinite client loops, as
2349 * seen e.g. with Windows XP SP3 when resume handle is 0 and
2350 * status is NT_STATUS_OK - gd */
2352 if (NT_STATUS_IS_OK(r.out.result) ||
2353 NT_STATUS_EQUAL(r.out.result, NT_STATUS_NO_MORE_ENTRIES) ||
2354 NT_STATUS_EQUAL(r.out.result, STATUS_MORE_ENTRIES))
2356 if (out_resume_handle <= in_resume_handle) {
2357 torture_comment(tctx, "EnumTrustDom failed - should have returned output resume_handle (0x%08x) larger than input resume handle (0x%08x)\n",
2358 out_resume_handle, in_resume_handle);
2363 /* NO_MORE_ENTRIES is allowed */
2364 if (NT_STATUS_EQUAL(r.out.result, NT_STATUS_NO_MORE_ENTRIES)) {
2365 if (domains.count == 0) {
2368 torture_comment(tctx, "EnumTrustDom failed - should have returned 0 trusted domains with 'NT_STATUS_NO_MORE_ENTRIES'\n");
2370 } else if (NT_STATUS_EQUAL(r.out.result, STATUS_MORE_ENTRIES)) {
2371 /* Windows 2003 gets this off by one on the first run */
2372 if (r.out.domains->count < 3 || r.out.domains->count > 4) {
2373 torture_comment(tctx, "EnumTrustDom didn't fill the buffer we "
2374 "asked it to (got %d, expected %d / %d == %d entries)\n",
2375 r.out.domains->count, LSA_ENUM_TRUST_DOMAIN_MULTIPLIER * 3,
2376 LSA_ENUM_TRUST_DOMAIN_MULTIPLIER, r.in.max_size);
2379 } else if (!NT_STATUS_IS_OK(r.out.result)) {
2380 torture_comment(tctx, "EnumTrustDom failed - %s\n", nt_errstr(r.out.result));
2384 if (domains.count == 0) {
2385 torture_comment(tctx, "EnumTrustDom failed - should have returned 'NT_STATUS_NO_MORE_ENTRIES' for 0 trusted domains\n");
2389 ret &= test_query_each_TrustDom(b, tctx, handle, &domains);
2391 in_resume_handle = out_resume_handle;
2393 } while ((NT_STATUS_EQUAL(r.out.result, STATUS_MORE_ENTRIES)));
2398 static bool test_EnumTrustDomEx(struct dcerpc_binding_handle *b,
2399 struct torture_context *tctx,
2400 struct policy_handle *handle)
2402 struct lsa_EnumTrustedDomainsEx r_ex;
2403 uint32_t resume_handle = 0;
2404 struct lsa_DomainListEx domains_ex;
2407 torture_comment(tctx, "\nTesting EnumTrustedDomainsEx\n");
2409 r_ex.in.handle = handle;
2410 r_ex.in.resume_handle = &resume_handle;
2411 r_ex.in.max_size = LSA_ENUM_TRUST_DOMAIN_EX_MULTIPLIER * 3;
2412 r_ex.out.domains = &domains_ex;
2413 r_ex.out.resume_handle = &resume_handle;
2415 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_EnumTrustedDomainsEx_r(b, tctx, &r_ex),
2416 "EnumTrustedDomainsEx failed");
2418 if (!(NT_STATUS_EQUAL(r_ex.out.result, STATUS_MORE_ENTRIES) || NT_STATUS_EQUAL(r_ex.out.result, NT_STATUS_NO_MORE_ENTRIES))) {
2419 torture_comment(tctx, "EnumTrustedDomainEx of zero size failed - %s\n", nt_errstr(r_ex.out.result));
2425 r_ex.in.handle = handle;
2426 r_ex.in.resume_handle = &resume_handle;
2427 r_ex.in.max_size = LSA_ENUM_TRUST_DOMAIN_EX_MULTIPLIER * 3;
2428 r_ex.out.domains = &domains_ex;
2429 r_ex.out.resume_handle = &resume_handle;
2431 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_EnumTrustedDomainsEx_r(b, tctx, &r_ex),
2432 "EnumTrustedDomainsEx failed");
2434 /* NO_MORE_ENTRIES is allowed */
2435 if (NT_STATUS_EQUAL(r_ex.out.result, NT_STATUS_NO_MORE_ENTRIES)) {
2436 if (domains_ex.count == 0) {
2439 torture_comment(tctx, "EnumTrustDomainsEx failed - should have returned 0 trusted domains with 'NT_STATUS_NO_MORE_ENTRIES'\n");
2441 } else if (NT_STATUS_EQUAL(r_ex.out.result, STATUS_MORE_ENTRIES)) {
2442 /* Windows 2003 gets this off by one on the first run */
2443 if (r_ex.out.domains->count < 3 || r_ex.out.domains->count > 4) {
2444 torture_comment(tctx, "EnumTrustDom didn't fill the buffer we "
2445 "asked it to (got %d, expected %d / %d == %d entries)\n",
2446 r_ex.out.domains->count,
2448 LSA_ENUM_TRUST_DOMAIN_EX_MULTIPLIER,
2449 r_ex.in.max_size / LSA_ENUM_TRUST_DOMAIN_EX_MULTIPLIER);
2451 } else if (!NT_STATUS_IS_OK(r_ex.out.result)) {
2452 torture_comment(tctx, "EnumTrustedDomainEx failed - %s\n", nt_errstr(r_ex.out.result));
2456 if (domains_ex.count == 0) {
2457 torture_comment(tctx, "EnumTrustDomainEx failed - should have returned 'NT_STATUS_NO_MORE_ENTRIES' for 0 trusted domains\n");
2461 ret &= test_query_each_TrustDomEx(b, tctx, handle, &domains_ex);
2463 } while ((NT_STATUS_EQUAL(r_ex.out.result, STATUS_MORE_ENTRIES)));
2469 static bool test_CreateTrustedDomain(struct dcerpc_binding_handle *b,
2470 struct torture_context *tctx,
2471 struct policy_handle *handle,
2472 uint32_t num_trusts)
2475 struct lsa_CreateTrustedDomain r;
2476 struct lsa_DomainInfo trustinfo;
2477 struct dom_sid **domsid;
2478 struct policy_handle *trustdom_handle;
2479 struct lsa_QueryTrustedDomainInfo q;
2480 union lsa_TrustedDomainInfo *info = NULL;
2483 torture_comment(tctx, "\nTesting CreateTrustedDomain for %d domains\n", num_trusts);
2485 if (!test_EnumTrustDom(b, tctx, handle)) {
2489 if (!test_EnumTrustDomEx(b, tctx, handle)) {
2493 domsid = talloc_array(tctx, struct dom_sid *, num_trusts);
2494 trustdom_handle = talloc_array(tctx, struct policy_handle, num_trusts);
2496 for (i=0; i< num_trusts; i++) {
2497 char *trust_name = talloc_asprintf(tctx, "torturedom%02d", i);
2498 char *trust_sid = talloc_asprintf(tctx, "S-1-5-21-97398-379795-100%02d", i);
2500 domsid[i] = dom_sid_parse_talloc(tctx, trust_sid);
2502 trustinfo.sid = domsid[i];
2503 init_lsa_String((struct lsa_String *)&trustinfo.name, trust_name);
2505 r.in.policy_handle = handle;
2506 r.in.info = &trustinfo;
2507 r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
2508 r.out.trustdom_handle = &trustdom_handle[i];
2510 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_CreateTrustedDomain_r(b, tctx, &r),
2511 "CreateTrustedDomain failed");
2512 if (NT_STATUS_EQUAL(r.out.result, NT_STATUS_OBJECT_NAME_COLLISION)) {
2513 test_DeleteTrustedDomain(b, tctx, handle, trustinfo.name);
2514 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_CreateTrustedDomain_r(b, tctx, &r),
2515 "CreateTrustedDomain failed");
2517 if (!NT_STATUS_IS_OK(r.out.result)) {
2518 torture_comment(tctx, "CreateTrustedDomain failed - %s\n", nt_errstr(r.out.result));
2522 q.in.trustdom_handle = &trustdom_handle[i];
2523 q.in.level = LSA_TRUSTED_DOMAIN_INFO_INFO_EX;
2525 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_QueryTrustedDomainInfo_r(b, tctx, &q),
2526 "QueryTrustedDomainInfo failed");
2527 if (!NT_STATUS_IS_OK(q.out.result)) {
2528 torture_comment(tctx, "QueryTrustedDomainInfo level %d failed - %s\n", q.in.level, nt_errstr(q.out.result));
2530 } else if (!q.out.info) {
2533 if (strcmp(info->info_ex.netbios_name.string, trustinfo.name.string) != 0) {
2534 torture_comment(tctx, "QueryTrustedDomainInfo returned inconsistent short name: %s != %s\n",
2535 info->info_ex.netbios_name.string, trustinfo.name.string);
2538 if (info->info_ex.trust_type != LSA_TRUST_TYPE_DOWNLEVEL) {
2539 torture_comment(tctx, "QueryTrustedDomainInfo of %s returned incorrect trust type %d != %d\n",
2540 trust_name, info->info_ex.trust_type, LSA_TRUST_TYPE_DOWNLEVEL);
2543 if (info->info_ex.trust_attributes != 0) {
2544 torture_comment(tctx, "QueryTrustedDomainInfo of %s returned incorrect trust attributes %d != %d\n",
2545 trust_name, info->info_ex.trust_attributes, 0);
2548 if (info->info_ex.trust_direction != LSA_TRUST_DIRECTION_OUTBOUND) {
2549 torture_comment(tctx, "QueryTrustedDomainInfo of %s returned incorrect trust direction %d != %d\n",
2550 trust_name, info->info_ex.trust_direction, LSA_TRUST_DIRECTION_OUTBOUND);
2557 /* now that we have some domains to look over, we can test the enum calls */
2558 if (!test_EnumTrustDom(b, tctx, handle)) {
2562 if (!test_EnumTrustDomEx(b, tctx, handle)) {
2566 for (i=0; i<num_trusts; i++) {
2567 if (!test_DeleteTrustedDomainBySid(b, tctx, handle, domsid[i])) {
2575 static bool gen_authinfo_internal(TALLOC_CTX *mem_ctx, const char *password,
2576 DATA_BLOB session_key,
2577 struct lsa_TrustDomainInfoAuthInfoInternal **_authinfo_internal)
2579 struct lsa_TrustDomainInfoAuthInfoInternal *authinfo_internal;
2580 struct trustDomainPasswords auth_struct;
2581 struct AuthenticationInformation *auth_info_array;
2582 size_t converted_size;
2583 DATA_BLOB auth_blob;
2584 enum ndr_err_code ndr_err;
2586 authinfo_internal = talloc_zero(mem_ctx, struct lsa_TrustDomainInfoAuthInfoInternal);
2587 if (authinfo_internal == NULL) {
2591 auth_info_array = talloc_array(mem_ctx,
2592 struct AuthenticationInformation, 1);
2593 if (auth_info_array == NULL) {
2597 generate_random_buffer(auth_struct.confounder, sizeof(auth_struct.confounder));
2599 auth_info_array[0].AuthType = TRUST_AUTH_TYPE_CLEAR;
2601 if (!convert_string_talloc(mem_ctx, CH_UNIX, CH_UTF16, password,
2603 &auth_info_array[0].AuthInfo.clear.password,
2608 auth_info_array[0].AuthInfo.clear.size = converted_size;
2610 auth_struct.outgoing.count = 1;
2611 auth_struct.outgoing.current.count = 1;
2612 auth_struct.outgoing.current.array = auth_info_array;
2613 auth_struct.outgoing.previous.count = 0;
2614 auth_struct.outgoing.previous.array = NULL;
2616 auth_struct.incoming.count = 1;
2617 auth_struct.incoming.current.count = 1;
2618 auth_struct.incoming.current.array = auth_info_array;
2619 auth_struct.incoming.previous.count = 0;
2620 auth_struct.incoming.previous.array = NULL;
2623 ndr_err = ndr_push_struct_blob(&auth_blob, mem_ctx, &auth_struct,
2624 (ndr_push_flags_fn_t)ndr_push_trustDomainPasswords);
2625 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
2629 arcfour_crypt_blob(auth_blob.data, auth_blob.length, &session_key);
2631 authinfo_internal->auth_blob.size = auth_blob.length;
2632 authinfo_internal->auth_blob.data = auth_blob.data;
2634 *_authinfo_internal = authinfo_internal;
2639 static bool gen_authinfo(TALLOC_CTX *mem_ctx, const char *password,
2640 struct lsa_TrustDomainInfoAuthInfo **_authinfo)
2642 struct lsa_TrustDomainInfoAuthInfo *authinfo;
2643 struct lsa_TrustDomainInfoBuffer *info_buffer;
2644 size_t converted_size;
2646 authinfo = talloc_zero(mem_ctx, struct lsa_TrustDomainInfoAuthInfo);
2647 if (authinfo == NULL) {
2651 info_buffer = talloc_zero(mem_ctx, struct lsa_TrustDomainInfoBuffer);
2652 if (info_buffer == NULL) {
2656 info_buffer->AuthType = TRUST_AUTH_TYPE_CLEAR;
2658 if (!convert_string_talloc(mem_ctx, CH_UNIX, CH_UTF16, password,
2660 &info_buffer->data.data,
2665 info_buffer->data.size = converted_size;
2667 authinfo->incoming_count = 1;
2668 authinfo->incoming_current_auth_info = info_buffer;
2669 authinfo->incoming_previous_auth_info = NULL;
2670 authinfo->outgoing_count = 1;
2671 authinfo->outgoing_current_auth_info = info_buffer;
2672 authinfo->outgoing_previous_auth_info = NULL;
2674 *_authinfo = authinfo;
2679 static bool check_pw_with_ServerAuthenticate3(struct dcerpc_pipe *p,
2680 struct torture_context *tctx,
2681 uint32_t negotiate_flags,
2682 struct cli_credentials *machine_credentials,
2683 struct netlogon_creds_CredentialState **creds_out)
2685 struct netr_ServerReqChallenge r;
2686 struct netr_ServerAuthenticate3 a;
2687 struct netr_Credential credentials1, credentials2, credentials3;
2688 struct netlogon_creds_CredentialState *creds;
2689 struct samr_Password mach_password;
2691 const char *machine_name;
2692 const char *plain_pass;
2693 struct dcerpc_binding_handle *b = p->binding_handle;
2695 machine_name = cli_credentials_get_workstation(machine_credentials);
2696 plain_pass = cli_credentials_get_password(machine_credentials);
2698 r.in.server_name = NULL;
2699 r.in.computer_name = machine_name;
2700 r.in.credentials = &credentials1;
2701 r.out.return_credentials = &credentials2;
2703 generate_random_buffer(credentials1.data, sizeof(credentials1.data));
2705 torture_assert_ntstatus_ok(tctx, dcerpc_netr_ServerReqChallenge_r(b, tctx, &r),
2706 "ServerReqChallenge failed");
2707 torture_assert_ntstatus_ok(tctx, r.out.result, "ServerReqChallenge failed");
2709 E_md4hash(plain_pass, mach_password.hash);
2711 a.in.server_name = NULL;
2712 a.in.account_name = talloc_asprintf(tctx, "%s$", machine_name);
2713 a.in.secure_channel_type = cli_credentials_get_secure_channel_type(machine_credentials);
2714 a.in.computer_name = machine_name;
2715 a.in.negotiate_flags = &negotiate_flags;
2716 a.in.credentials = &credentials3;
2717 a.out.return_credentials = &credentials3;
2718 a.out.negotiate_flags = &negotiate_flags;
2721 creds = netlogon_creds_client_init(tctx, a.in.account_name,
2723 &credentials1, &credentials2,
2724 &mach_password, &credentials3,
2727 torture_assert(tctx, creds != NULL, "memory allocation");
2729 torture_assert_ntstatus_ok(tctx, dcerpc_netr_ServerAuthenticate3_r(b, tctx, &a),
2730 "ServerAuthenticate3 failed");
2731 if (!NT_STATUS_IS_OK(a.out.result)) {
2732 if (!NT_STATUS_EQUAL(a.out.result, NT_STATUS_ACCESS_DENIED)) {
2733 torture_assert_ntstatus_ok(tctx, a.out.result,
2734 "ServerAuthenticate3 failed");
2738 torture_assert(tctx, netlogon_creds_client_check(creds, &credentials3), "Credential chaining failed");
2740 /* Prove that requesting a challenge again won't break it */
2741 torture_assert_ntstatus_ok(tctx, dcerpc_netr_ServerReqChallenge_r(b, tctx, &r),
2742 "ServerReqChallenge failed");
2743 torture_assert_ntstatus_ok(tctx, r.out.result, "ServerReqChallenge failed");
2749 static bool check_dom_trust_pw(struct dcerpc_pipe *p,
2750 struct torture_context *tctx,
2751 const char *trusted_dom_name,
2752 const char *password)
2754 struct cli_credentials *credentials;
2756 struct netlogon_creds_CredentialState *creds;
2757 struct dcerpc_pipe *pipe;
2761 credentials = cli_credentials_init(tctx);
2762 if (credentials == NULL) {
2766 dummy = talloc_asprintf(tctx, "%s$", trusted_dom_name);
2767 if (dummy == NULL) {
2771 cli_credentials_set_username(credentials, dummy, CRED_SPECIFIED);
2772 cli_credentials_set_password(credentials, password, CRED_SPECIFIED);
2773 cli_credentials_set_workstation(credentials,
2774 trusted_dom_name, CRED_SPECIFIED);
2775 cli_credentials_set_secure_channel_type(credentials, SEC_CHAN_DOMAIN);
2777 status = dcerpc_pipe_connect_b(tctx, &pipe, p->binding,
2778 &ndr_table_netlogon,
2779 cli_credentials_init_anon(tctx),
2780 tctx->ev, tctx->lp_ctx);
2781 if (!NT_STATUS_IS_OK(status)) {
2782 torture_comment(tctx, "dcerpc_pipe_connect_b failed.\n");
2786 ok = check_pw_with_ServerAuthenticate3(pipe, tctx,
2787 NETLOGON_NEG_AUTH2_ADS_FLAGS,
2788 credentials, &creds);
2794 static bool test_CreateTrustedDomainEx_common(struct dcerpc_pipe *p,
2795 struct torture_context *tctx,
2796 struct policy_handle *handle,
2797 uint32_t num_trusts,
2802 struct lsa_CreateTrustedDomainEx r;
2803 struct lsa_CreateTrustedDomainEx2 r2;
2804 struct lsa_TrustDomainInfoInfoEx trustinfo;
2805 struct lsa_TrustDomainInfoAuthInfoInternal *authinfo_internal;
2806 struct lsa_TrustDomainInfoAuthInfo *authinfo;
2807 struct dom_sid **domsid;
2808 struct policy_handle *trustdom_handle;
2809 struct lsa_QueryTrustedDomainInfo q;
2810 union lsa_TrustedDomainInfo *info = NULL;
2811 DATA_BLOB session_key;
2813 struct dcerpc_binding_handle *b = p->binding_handle;
2816 torture_comment(tctx, "\nTesting CreateTrustedDomainEx2 for %d domains\n", num_trusts);
2818 torture_comment(tctx, "\nTesting CreateTrustedDomainEx for %d domains\n", num_trusts);
2821 domsid = talloc_array(tctx, struct dom_sid *, num_trusts);
2822 trustdom_handle = talloc_array(tctx, struct policy_handle, num_trusts);
2824 status = dcerpc_fetch_session_key(p, &session_key);
2825 if (!NT_STATUS_IS_OK(status)) {
2826 torture_comment(tctx, "dcerpc_fetch_session_key failed - %s\n", nt_errstr(status));
2830 for (i=0; i< num_trusts; i++) {
2831 char *trust_name = talloc_asprintf(tctx, "torturedom%02d", i);
2832 char *trust_name_dns = talloc_asprintf(tctx, "torturedom%02d.samba.example.com", i);
2833 char *trust_sid = talloc_asprintf(tctx, "S-1-5-21-97398-379795-100%02d", i);
2835 domsid[i] = dom_sid_parse_talloc(tctx, trust_sid);
2837 trustinfo.sid = domsid[i];
2838 trustinfo.netbios_name.string = trust_name;
2839 trustinfo.domain_name.string = trust_name_dns;
2841 /* Create inbound, some outbound, and some
2842 * bi-directional trusts in a repeating pattern based
2845 /* 1 == inbound, 2 == outbound, 3 == both */
2846 trustinfo.trust_direction = (i % 3) + 1;
2848 /* Try different trust types too */
2850 /* 1 == downlevel (NT4), 2 == uplevel (ADS), 3 == MIT (kerberos but not AD) */
2851 trustinfo.trust_type = (((i / 3) + 1) % 3) + 1;
2853 trustinfo.trust_attributes = LSA_TRUST_ATTRIBUTE_USES_RC4_ENCRYPTION;
2855 if (!gen_authinfo_internal(tctx, TRUSTPW, session_key, &authinfo_internal)) {
2856 torture_comment(tctx, "gen_authinfo_internal failed");
2860 if (!gen_authinfo(tctx, TRUSTPW, &authinfo)) {
2861 torture_comment(tctx, "gen_authinfonfo failed");
2867 r2.in.policy_handle = handle;
2868 r2.in.info = &trustinfo;
2869 r2.in.auth_info_internal = authinfo_internal;
2870 r2.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
2871 r2.out.trustdom_handle = &trustdom_handle[i];
2873 torture_assert_ntstatus_ok(tctx,
2874 dcerpc_lsa_CreateTrustedDomainEx2_r(b, tctx, &r2),
2875 "CreateTrustedDomainEx2 failed");
2877 status = r2.out.result;
2880 r.in.policy_handle = handle;
2881 r.in.info = &trustinfo;
2882 r.in.auth_info = authinfo;
2883 r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
2884 r.out.trustdom_handle = &trustdom_handle[i];
2886 torture_assert_ntstatus_ok(tctx,
2887 dcerpc_lsa_CreateTrustedDomainEx_r(b, tctx, &r),
2888 "CreateTrustedDomainEx failed");
2890 status = r.out.result;
2893 if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) {
2894 test_DeleteTrustedDomain(b, tctx, handle, trustinfo.netbios_name);
2896 torture_assert_ntstatus_ok(tctx,
2897 dcerpc_lsa_CreateTrustedDomainEx2_r(b, tctx, &r2),
2898 "CreateTrustedDomainEx2 failed");
2899 status = r2.out.result;
2901 torture_assert_ntstatus_ok(tctx,
2902 dcerpc_lsa_CreateTrustedDomainEx_r(b, tctx, &r),
2903 "CreateTrustedDomainEx2 failed");
2904 status = r.out.result;
2907 if (!NT_STATUS_IS_OK(status)) {
2908 torture_comment(tctx, "CreateTrustedDomainEx failed2 - %s\n", nt_errstr(status));
2911 /* For outbound and MIT trusts there is no trust account */
2912 if (trustinfo.trust_direction != 2 &&
2913 trustinfo.trust_type != 3) {
2915 if (torture_setting_bool(tctx, "samba3", false) ||
2916 torture_setting_bool(tctx, "samba4", false)) {
2917 torture_comment(tctx, "skipping trusted domain auth tests against samba");
2919 if (check_dom_trust_pw(p, tctx, trust_name,
2921 torture_comment(tctx, "Password check passed unexpectedly\n");
2924 if (!check_dom_trust_pw(p, tctx, trust_name,
2926 torture_comment(tctx, "Password check failed\n");
2932 q.in.trustdom_handle = &trustdom_handle[i];
2933 q.in.level = LSA_TRUSTED_DOMAIN_INFO_INFO_EX;
2935 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_QueryTrustedDomainInfo_r(b, tctx, &q),
2936 "QueryTrustedDomainInfo failed");
2937 if (!NT_STATUS_IS_OK(q.out.result)) {
2938 torture_comment(tctx, "QueryTrustedDomainInfo level 1 failed - %s\n", nt_errstr(q.out.result));
2940 } else if (!q.out.info) {
2941 torture_comment(tctx, "QueryTrustedDomainInfo level 1 failed to return an info pointer\n");
2944 if (strcmp(info->info_ex.netbios_name.string, trustinfo.netbios_name.string) != 0) {
2945 torture_comment(tctx, "QueryTrustedDomainInfo returned inconsistent short name: %s != %s\n",
2946 info->info_ex.netbios_name.string, trustinfo.netbios_name.string);
2949 if (info->info_ex.trust_type != trustinfo.trust_type) {
2950 torture_comment(tctx, "QueryTrustedDomainInfo of %s returned incorrect trust type %d != %d\n",
2951 trust_name, info->info_ex.trust_type, trustinfo.trust_type);
2954 if (info->info_ex.trust_attributes != LSA_TRUST_ATTRIBUTE_USES_RC4_ENCRYPTION) {
2955 torture_comment(tctx, "QueryTrustedDomainInfo of %s returned incorrect trust attributes %d != %d\n",
2956 trust_name, info->info_ex.trust_attributes, LSA_TRUST_ATTRIBUTE_USES_RC4_ENCRYPTION);
2959 if (info->info_ex.trust_direction != trustinfo.trust_direction) {
2960 torture_comment(tctx, "QueryTrustedDomainInfo of %s returned incorrect trust direction %d != %d\n",
2961 trust_name, info->info_ex.trust_direction, trustinfo.trust_direction);
2968 /* now that we have some domains to look over, we can test the enum calls */
2969 if (!test_EnumTrustDom(b, tctx, handle)) {
2970 torture_comment(tctx, "test_EnumTrustDom failed\n");
2974 if (!test_EnumTrustDomEx(b, tctx, handle)) {
2975 torture_comment(tctx, "test_EnumTrustDomEx failed\n");
2979 for (i=0; i<num_trusts; i++) {
2980 if (!test_DeleteTrustedDomainBySid(b, tctx, handle, domsid[i])) {
2981 torture_comment(tctx, "test_DeleteTrustedDomainBySid failed\n");
2989 static bool test_CreateTrustedDomainEx2(struct dcerpc_pipe *p,
2990 struct torture_context *tctx,
2991 struct policy_handle *handle,
2992 uint32_t num_trusts)
2994 return test_CreateTrustedDomainEx_common(p, tctx, handle, num_trusts, true);
2997 static bool test_CreateTrustedDomainEx(struct dcerpc_pipe *p,
2998 struct torture_context *tctx,
2999 struct policy_handle *handle,
3000 uint32_t num_trusts)
3002 return test_CreateTrustedDomainEx_common(p, tctx, handle, num_trusts, false);
3005 static bool test_QueryDomainInfoPolicy(struct dcerpc_binding_handle *b,
3006 struct torture_context *tctx,
3007 struct policy_handle *handle)
3009 struct lsa_QueryDomainInformationPolicy r;
3010 union lsa_DomainInformationPolicy *info = NULL;
3014 if (torture_setting_bool(tctx, "samba3", false)) {
3015 torture_skip(tctx, "skipping QueryDomainInformationPolicy test\n");
3018 torture_comment(tctx, "\nTesting QueryDomainInformationPolicy\n");
3021 r.in.handle = handle;
3025 torture_comment(tctx, "\nTrying QueryDomainInformationPolicy level %d\n", i);
3027 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_QueryDomainInformationPolicy_r(b, tctx, &r),
3028 "QueryDomainInformationPolicy failed");
3030 /* If the server does not support EFS, then this is the correct return */
3031 if (i == LSA_DOMAIN_INFO_POLICY_EFS && NT_STATUS_EQUAL(r.out.result, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
3033 } else if (!NT_STATUS_IS_OK(r.out.result)) {
3034 torture_comment(tctx, "QueryDomainInformationPolicy failed - %s\n", nt_errstr(r.out.result));
3044 static bool test_QueryInfoPolicyCalls( bool version2,
3045 struct dcerpc_binding_handle *b,
3046 struct torture_context *tctx,
3047 struct policy_handle *handle)
3049 struct lsa_QueryInfoPolicy r;
3050 union lsa_PolicyInformation *info = NULL;
3053 const char *call = talloc_asprintf(tctx, "QueryInfoPolicy%s", version2 ? "2":"");
3055 torture_comment(tctx, "\nTesting %s\n", call);
3057 if (version2 && torture_setting_bool(tctx, "samba3", false)) {
3058 torture_skip(tctx, "skipping QueryInfoPolicy2 tests\n");
3061 for (i=1;i<=14;i++) {
3062 r.in.handle = handle;
3066 torture_comment(tctx, "\nTrying %s level %d\n", call, i);
3069 /* We can perform the cast, because both types are
3070 structurally equal */
3071 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_QueryInfoPolicy2_r(b, tctx,
3072 (struct lsa_QueryInfoPolicy2*) &r),
3073 "QueryInfoPolicy2 failed");
3075 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_QueryInfoPolicy_r(b, tctx, &r),
3076 "QueryInfoPolicy2 failed");
3079 case LSA_POLICY_INFO_MOD:
3080 case LSA_POLICY_INFO_AUDIT_FULL_SET:
3081 case LSA_POLICY_INFO_AUDIT_FULL_QUERY:
3082 if (!NT_STATUS_EQUAL(r.out.result, NT_STATUS_INVALID_PARAMETER)) {
3083 torture_comment(tctx, "Server should have failed level %u: %s\n", i, nt_errstr(r.out.result));
3087 case LSA_POLICY_INFO_DOMAIN:
3088 case LSA_POLICY_INFO_ACCOUNT_DOMAIN:
3089 case LSA_POLICY_INFO_REPLICA:
3090 case LSA_POLICY_INFO_QUOTA:
3091 case LSA_POLICY_INFO_ROLE:
3092 case LSA_POLICY_INFO_AUDIT_LOG:
3093 case LSA_POLICY_INFO_AUDIT_EVENTS:
3094 case LSA_POLICY_INFO_PD:
3095 if (!NT_STATUS_IS_OK(r.out.result)) {
3096 torture_comment(tctx, "%s failed - %s\n", call, nt_errstr(r.out.result));
3100 case LSA_POLICY_INFO_L_ACCOUNT_DOMAIN:
3101 case LSA_POLICY_INFO_DNS_INT:
3102 case LSA_POLICY_INFO_DNS:
3103 if (torture_setting_bool(tctx, "samba3", false)) {
3104 /* Other levels not implemented yet */
3105 if (!NT_STATUS_EQUAL(r.out.result, NT_STATUS_INVALID_INFO_CLASS)) {
3106 torture_comment(tctx, "%s failed - %s\n", call, nt_errstr(r.out.result));
3109 } else if (!NT_STATUS_IS_OK(r.out.result)) {
3110 torture_comment(tctx, "%s failed - %s\n", call, nt_errstr(r.out.result));
3115 if (torture_setting_bool(tctx, "samba4", false)) {
3116 /* Other levels not implemented yet */
3117 if (!NT_STATUS_EQUAL(r.out.result, NT_STATUS_INVALID_INFO_CLASS)) {
3118 torture_comment(tctx, "%s failed - %s\n", call, nt_errstr(r.out.result));
3121 } else if (!NT_STATUS_IS_OK(r.out.result)) {
3122 torture_comment(tctx, "%s failed - %s\n", call, nt_errstr(r.out.result));
3128 if (NT_STATUS_IS_OK(r.out.result) && (i == LSA_POLICY_INFO_DNS
3129 || i == LSA_POLICY_INFO_DNS_INT)) {
3130 /* Let's look up some of these names */
3132 struct lsa_TransNameArray tnames;
3134 tnames.names = talloc_zero_array(tctx, struct lsa_TranslatedName, tnames.count);
3135 tnames.names[0].name.string = info->dns.name.string;
3136 tnames.names[0].sid_type = SID_NAME_DOMAIN;
3137 tnames.names[1].name.string = info->dns.dns_domain.string;
3138 tnames.names[1].sid_type = SID_NAME_DOMAIN;
3139 tnames.names[2].name.string = talloc_asprintf(tctx, "%s\\", info->dns.name.string);
3140 tnames.names[2].sid_type = SID_NAME_DOMAIN;
3141 tnames.names[3].name.string = talloc_asprintf(tctx, "%s\\", info->dns.dns_domain.string);
3142 tnames.names[3].sid_type = SID_NAME_DOMAIN;
3143 tnames.names[4].name.string = talloc_asprintf(tctx, "%s\\guest", info->dns.name.string);
3144 tnames.names[4].sid_type = SID_NAME_USER;
3145 tnames.names[5].name.string = talloc_asprintf(tctx, "%s\\krbtgt", info->dns.name.string);
3146 tnames.names[5].sid_type = SID_NAME_USER;
3147 tnames.names[6].name.string = talloc_asprintf(tctx, "%s\\guest", info->dns.dns_domain.string);
3148 tnames.names[6].sid_type = SID_NAME_USER;
3149 tnames.names[7].name.string = talloc_asprintf(tctx, "%s\\krbtgt", info->dns.dns_domain.string);
3150 tnames.names[7].sid_type = SID_NAME_USER;
3151 tnames.names[8].name.string = talloc_asprintf(tctx, "krbtgt@%s", info->dns.name.string);
3152 tnames.names[8].sid_type = SID_NAME_USER;
3153 tnames.names[9].name.string = talloc_asprintf(tctx, "krbtgt@%s", info->dns.dns_domain.string);
3154 tnames.names[9].sid_type = SID_NAME_USER;
3155 tnames.names[10].name.string = talloc_asprintf(tctx, "%s\\"TEST_MACHINENAME "$", info->dns.name.string);
3156 tnames.names[10].sid_type = SID_NAME_USER;
3157 tnames.names[11].name.string = talloc_asprintf(tctx, "%s\\"TEST_MACHINENAME "$", info->dns.dns_domain.string);
3158 tnames.names[11].sid_type = SID_NAME_USER;
3159 tnames.names[12].name.string = talloc_asprintf(tctx, TEST_MACHINENAME "$@%s", info->dns.name.string);
3160 tnames.names[12].sid_type = SID_NAME_USER;
3161 tnames.names[13].name.string = talloc_asprintf(tctx, TEST_MACHINENAME "$@%s", info->dns.dns_domain.string);
3162 tnames.names[13].sid_type = SID_NAME_USER;
3163 ret &= test_LookupNames(b, tctx, handle, &tnames);
3171 static bool test_QueryInfoPolicy(struct dcerpc_binding_handle *b,
3172 struct torture_context *tctx,
3173 struct policy_handle *handle)
3175 return test_QueryInfoPolicyCalls(false, b, tctx, handle);
3178 static bool test_QueryInfoPolicy2(struct dcerpc_binding_handle *b,
3179 struct torture_context *tctx,
3180 struct policy_handle *handle)
3182 return test_QueryInfoPolicyCalls(true, b, tctx, handle);
3185 static bool test_GetUserName(struct dcerpc_binding_handle *b,
3186 struct torture_context *tctx)
3188 struct lsa_GetUserName r;
3190 struct lsa_String *authority_name_p = NULL;
3191 struct lsa_String *account_name_p = NULL;
3193 torture_comment(tctx, "\nTesting GetUserName\n");
3195 r.in.system_name = "\\";
3196 r.in.account_name = &account_name_p;
3197 r.in.authority_name = NULL;
3198 r.out.account_name = &account_name_p;
3200 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_GetUserName_r(b, tctx, &r),
3201 "GetUserName failed");
3203 if (!NT_STATUS_IS_OK(r.out.result)) {
3204 torture_comment(tctx, "GetUserName failed - %s\n", nt_errstr(r.out.result));
3208 account_name_p = NULL;
3209 r.in.account_name = &account_name_p;
3210 r.in.authority_name = &authority_name_p;
3211 r.out.account_name = &account_name_p;
3213 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_GetUserName_r(b, tctx, &r),
3214 "GetUserName failed");
3216 if (!NT_STATUS_IS_OK(r.out.result)) {
3217 torture_comment(tctx, "GetUserName failed - %s\n", nt_errstr(r.out.result));
3224 static bool test_GetUserName_fail(struct dcerpc_binding_handle *b,
3225 struct torture_context *tctx)
3227 struct lsa_GetUserName r;
3228 struct lsa_String *account_name_p = NULL;
3231 torture_comment(tctx, "\nTesting GetUserName_fail\n");
3233 r.in.system_name = "\\";
3234 r.in.account_name = &account_name_p;
3235 r.in.authority_name = NULL;
3236 r.out.account_name = &account_name_p;
3238 status = dcerpc_lsa_GetUserName_r(b, tctx, &r);
3239 if (!NT_STATUS_IS_OK(status)) {
3240 if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) {
3241 torture_comment(tctx,
3242 "GetUserName correctly returned with "
3248 torture_assert_ntstatus_equal(tctx,
3250 NT_STATUS_ACCESS_DENIED,
3251 "GetUserName return value should "
3252 "be ACCESS_DENIED");
3256 if (!NT_STATUS_IS_OK(r.out.result)) {
3257 if (NT_STATUS_EQUAL(r.out.result, NT_STATUS_ACCESS_DENIED) ||
3258 NT_STATUS_EQUAL(r.out.result, NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED)) {
3259 torture_comment(tctx,
3260 "GetUserName correctly returned with "
3262 nt_errstr(r.out.result));
3267 torture_assert_ntstatus_equal(tctx,
3270 "GetUserName return value should be "
3276 bool test_lsa_Close(struct dcerpc_binding_handle *b,
3277 struct torture_context *tctx,
3278 struct policy_handle *handle)
3281 struct policy_handle handle2;
3283 torture_comment(tctx, "\nTesting Close\n");
3285 r.in.handle = handle;
3286 r.out.handle = &handle2;
3288 torture_assert_ntstatus_ok(tctx, dcerpc_lsa_Close_r(b, tctx, &r),
3290 torture_assert_ntstatus_ok(tctx, r.out.result,
3293 torture_assert_ntstatus_equal(tctx, dcerpc_lsa_Close_r(b, tctx, &r),
3294 NT_STATUS_RPC_SS_CONTEXT_MISMATCH, "Close should failed");
3296 torture_comment(tctx, "\n");
3301 bool torture_rpc_lsa(struct torture_context *tctx)
3304 struct dcerpc_pipe *p;
3306 struct policy_handle *handle = NULL;
3307 struct test_join *join = NULL;
3308 struct cli_credentials *machine_creds;
3309 struct dcerpc_binding_handle *b;
3311 status = torture_rpc_connection(tctx, &p, &ndr_table_lsarpc);
3312 if (!NT_STATUS_IS_OK(status)) {
3315 b = p->binding_handle;
3317 /* Test lsaLookupSids3 and lsaLookupNames4 over tcpip */
3318 if (p->binding->transport == NCACN_IP_TCP) {
3319 if (!test_OpenPolicy_fail(b, tctx)) {
3323 if (!test_OpenPolicy2_fail(b, tctx)) {
3327 if (!test_many_LookupSids(p, tctx, handle)) {
3334 if (!test_OpenPolicy(b, tctx)) {
3338 if (!test_lsa_OpenPolicy2(b, tctx, &handle)) {
3343 join = torture_join_domain(tctx, TEST_MACHINENAME, ACB_WSTRUST, &machine_creds);
3348 if (!test_LookupSids_async(b, tctx, handle)) {
3352 if (!test_QueryDomainInfoPolicy(b, tctx, handle)) {
3356 if (!test_CreateSecret(p, tctx, handle)) {
3360 if (!test_QueryInfoPolicy(b, tctx, handle)) {
3364 if (!test_QueryInfoPolicy2(b, tctx, handle)) {
3368 if (!test_Delete(b, tctx, handle)) {
3372 if (!test_many_LookupSids(p, tctx, handle)) {
3376 if (!test_lsa_Close(b, tctx, handle)) {
3380 torture_leave_domain(tctx, join);
3383 if (!test_many_LookupSids(p, tctx, handle)) {
3388 if (!test_GetUserName(b, tctx)) {
3395 bool torture_rpc_lsa_get_user(struct torture_context *tctx)
3398 struct dcerpc_pipe *p;
3400 struct dcerpc_binding_handle *b;
3402 status = torture_rpc_connection(tctx, &p, &ndr_table_lsarpc);
3403 if (!NT_STATUS_IS_OK(status)) {
3406 b = p->binding_handle;
3408 if (p->binding->transport == NCACN_IP_TCP) {
3409 if (!test_GetUserName_fail(b, tctx)) {
3415 if (!test_GetUserName(b, tctx)) {
3422 static bool testcase_LookupNames(struct torture_context *tctx,
3423 struct dcerpc_pipe *p)
3426 struct policy_handle *handle;
3427 struct lsa_TransNameArray tnames;
3428 struct lsa_TransNameArray2 tnames2;
3429 struct dcerpc_binding_handle *b = p->binding_handle;
3431 if (p->binding->transport != NCACN_NP &&
3432 p->binding->transport != NCALRPC) {
3433 torture_comment(tctx, "testcase_LookupNames is only available "
3434 "over NCACN_NP or NCALRPC");
3438 if (!test_OpenPolicy(b, tctx)) {
3442 if (!test_lsa_OpenPolicy2(b, tctx, &handle)) {
3451 tnames.names = talloc_array(tctx, struct lsa_TranslatedName, tnames.count);
3452 ZERO_STRUCT(tnames.names[0]);
3453 tnames.names[0].name.string = "BUILTIN";
3454 tnames.names[0].sid_type = SID_NAME_DOMAIN;
3456 if (!test_LookupNames(b, tctx, handle, &tnames)) {
3461 tnames2.names = talloc_array(tctx, struct lsa_TranslatedName2, tnames2.count);
3462 ZERO_STRUCT(tnames2.names[0]);
3463 tnames2.names[0].name.string = "BUILTIN";
3464 tnames2.names[0].sid_type = SID_NAME_DOMAIN;
3466 if (!test_LookupNames2(b, tctx, handle, &tnames2, true)) {
3470 if (!test_LookupNames3(b, tctx, handle, &tnames2, true)) {
3474 if (!test_LookupNames_wellknown(b, tctx, handle)) {
3478 if (!test_LookupNames_NULL(b, tctx, handle)) {
3482 if (!test_LookupNames_bogus(b, tctx, handle)) {
3486 if (!test_lsa_Close(b, tctx, handle)) {
3493 struct torture_suite *torture_rpc_lsa_lookup_names(TALLOC_CTX *mem_ctx)
3495 struct torture_suite *suite;
3496 struct torture_rpc_tcase *tcase;
3498 suite = torture_suite_create(mem_ctx, "lsa.lookupnames");
3500 tcase = torture_suite_add_rpc_iface_tcase(suite, "lsa",
3502 torture_rpc_tcase_add_test(tcase, "LookupNames",
3503 testcase_LookupNames);
3508 struct lsa_trustdom_state {
3509 uint32_t num_trusts;
3512 static bool testcase_TrustedDomains(struct torture_context *tctx,
3513 struct dcerpc_pipe *p,
3517 struct policy_handle *handle;
3518 struct lsa_trustdom_state *state =
3519 talloc_get_type_abort(data, struct lsa_trustdom_state);
3520 struct dcerpc_binding_handle *b = p->binding_handle;
3522 if (p->binding->transport != NCACN_NP &&
3523 p->binding->transport != NCALRPC) {
3524 torture_comment(tctx, "testcase_TrustedDomains is only available "
3525 "over NCACN_NP or NCALRPC");
3529 torture_comment(tctx, "Testing %d domains\n", state->num_trusts);
3531 if (!test_OpenPolicy(b, tctx)) {
3535 if (!test_lsa_OpenPolicy2(b, tctx, &handle)) {
3543 if (!test_CreateTrustedDomain(b, tctx, handle, state->num_trusts)) {
3547 if (!test_CreateTrustedDomainEx(p, tctx, handle, state->num_trusts)) {
3551 if (!test_CreateTrustedDomainEx2(p, tctx, handle, state->num_trusts)) {
3555 if (!test_lsa_Close(b, tctx, handle)) {
3562 struct torture_suite *torture_rpc_lsa_trusted_domains(TALLOC_CTX *mem_ctx)
3564 struct torture_suite *suite;
3565 struct torture_rpc_tcase *tcase;
3566 struct lsa_trustdom_state *state;
3568 state = talloc(mem_ctx, struct lsa_trustdom_state);
3570 state->num_trusts = 12;
3572 suite = torture_suite_create(mem_ctx, "lsa.trusted.domains");
3574 tcase = torture_suite_add_rpc_iface_tcase(suite, "lsa",
3576 torture_rpc_tcase_add_test_ex(tcase, "TrustedDomains",
3577 testcase_TrustedDomains,
3583 static bool testcase_Privileges(struct torture_context *tctx,
3584 struct dcerpc_pipe *p)
3587 struct policy_handle *handle;
3588 struct dcerpc_binding_handle *b = p->binding_handle;
3590 if (p->binding->transport != NCACN_NP &&
3591 p->binding->transport != NCALRPC) {
3592 torture_comment(tctx, "testcase_Privileges is only available "
3593 "over NCACN_NP or NCALRPC");
3597 if (!test_OpenPolicy(b, tctx)) {
3601 if (!test_lsa_OpenPolicy2(b, tctx, &handle)) {
3609 if (!test_CreateAccount(b, tctx, handle)) {
3613 if (!test_EnumAccounts(b, tctx, handle)) {
3617 if (!test_EnumPrivs(b, tctx, handle)) {
3621 if (!test_lsa_Close(b, tctx, handle)) {
3629 struct torture_suite *torture_rpc_lsa_privileges(TALLOC_CTX *mem_ctx)
3631 struct torture_suite *suite;
3632 struct torture_rpc_tcase *tcase;
3634 suite = torture_suite_create(mem_ctx, "lsa.privileges");
3636 tcase = torture_suite_add_rpc_iface_tcase(suite, "lsa",
3638 torture_rpc_tcase_add_test(tcase, "Privileges",
3639 testcase_Privileges);