r884: convert samba4 to use [u]int32_t instead of [u]int32
[ira/wip.git] / source4 / torture / rpc / lsa.c
1 /* 
2    Unix SMB/CIFS implementation.
3    test suite for lsa rpc operations
4
5    Copyright (C) Andrew Tridgell 2003
6    
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11    
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16    
17    You should have received a copy of the GNU General Public License
18    along with this program; if not, write to the Free Software
19    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22 #include "includes.h"
23
24 static void init_lsa_Name(struct lsa_Name *name, const char *s)
25 {
26         name->name = s;
27 }
28
29 static BOOL test_OpenPolicy(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx)
30 {
31         struct lsa_ObjectAttribute attr;
32         struct policy_handle handle;
33         struct lsa_QosInfo qos;
34         struct lsa_OpenPolicy r;
35         NTSTATUS status;
36         uint16 system_name = '\\';
37
38         printf("\ntesting OpenPolicy\n");
39
40         qos.len = 0;
41         qos.impersonation_level = 2;
42         qos.context_mode = 1;
43         qos.effective_only = 0;
44
45         attr.len = 0;
46         attr.root_dir = NULL;
47         attr.object_name = NULL;
48         attr.attributes = 0;
49         attr.sec_desc = NULL;
50         attr.sec_qos = &qos;
51
52         r.in.system_name = &system_name;
53         r.in.attr = &attr;
54         r.in.desired_access = SEC_RIGHTS_MAXIMUM_ALLOWED;
55         r.out.handle = &handle;
56
57         status = dcerpc_lsa_OpenPolicy(p, mem_ctx, &r);
58         if (!NT_STATUS_IS_OK(status)) {
59                 printf("OpenPolicy failed - %s\n", nt_errstr(status));
60                 return False;
61         }
62
63         return True;
64 }
65
66
67 static BOOL test_OpenPolicy2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, 
68                              struct policy_handle *handle)
69 {
70         struct lsa_ObjectAttribute attr;
71         struct lsa_QosInfo qos;
72         struct lsa_OpenPolicy2 r;
73         NTSTATUS status;
74
75         printf("\ntesting OpenPolicy2\n");
76
77         qos.len = 0;
78         qos.impersonation_level = 2;
79         qos.context_mode = 1;
80         qos.effective_only = 0;
81
82         attr.len = 0;
83         attr.root_dir = NULL;
84         attr.object_name = NULL;
85         attr.attributes = 0;
86         attr.sec_desc = NULL;
87         attr.sec_qos = &qos;
88
89         r.in.system_name = "\\";
90         r.in.attr = &attr;
91         r.in.desired_access = SEC_RIGHTS_MAXIMUM_ALLOWED;
92         r.out.handle = handle;
93
94         status = dcerpc_lsa_OpenPolicy2(p, mem_ctx, &r);
95         if (!NT_STATUS_IS_OK(status)) {
96                 printf("OpenPolicy2 failed - %s\n", nt_errstr(status));
97                 return False;
98         }
99
100         return True;
101 }
102
103 static BOOL test_LookupNames(struct dcerpc_pipe *p, 
104                             TALLOC_CTX *mem_ctx, 
105                             struct policy_handle *handle,
106                             struct lsa_TransNameArray *tnames)
107 {
108         struct lsa_LookupNames r;
109         struct lsa_TransSidArray sids;
110         struct lsa_Name *names;
111         uint32_t count = 0;
112         NTSTATUS status;
113         int i;
114
115         printf("\nTesting LookupNames\n");
116
117         sids.count = 0;
118         sids.sids = NULL;
119
120         names = talloc(mem_ctx, tnames->count * sizeof(names[0]));
121         for (i=0;i<tnames->count;i++) {
122                 init_lsa_Name(&names[i], tnames->names[i].name.name);
123         }
124
125         r.in.handle = handle;
126         r.in.num_names = tnames->count;
127         r.in.names = names;
128         r.in.sids = &sids;
129         r.in.level = 1;
130         r.in.count = &count;
131         r.out.count = &count;
132         r.out.sids = &sids;
133
134         status = dcerpc_lsa_LookupNames(p, mem_ctx, &r);
135         if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status, STATUS_SOME_UNMAPPED)) {
136                 printf("LookupNames failed - %s\n", nt_errstr(status));
137                 return False;
138         }
139
140         printf("\n");
141
142         return True;
143 }
144
145
146 static BOOL test_LookupSids(struct dcerpc_pipe *p, 
147                             TALLOC_CTX *mem_ctx, 
148                             struct policy_handle *handle,
149                             struct lsa_SidArray *sids)
150 {
151         struct lsa_LookupSids r;
152         struct lsa_TransNameArray names;
153         uint32_t count = sids->num_sids;
154         NTSTATUS status;
155
156         printf("\nTesting LookupSids\n");
157
158         names.count = 0;
159         names.names = NULL;
160
161         r.in.handle = handle;
162         r.in.sids = sids;
163         r.in.names = &names;
164         r.in.level = 1;
165         r.in.count = &count;
166         r.out.count = &count;
167         r.out.names = &names;
168
169         status = dcerpc_lsa_LookupSids(p, mem_ctx, &r);
170         if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status, STATUS_SOME_UNMAPPED)) {
171                 printf("LookupSids failed - %s\n", nt_errstr(status));
172                 return False;
173         }
174
175         printf("\n");
176
177         if (!test_LookupNames(p, mem_ctx, handle, &names)) {
178                 return False;
179         }
180
181         return True;
182 }
183
184 static BOOL test_LookupPrivName(struct dcerpc_pipe *p, 
185                                 TALLOC_CTX *mem_ctx, 
186                                 struct policy_handle *handle,
187                                 struct lsa_LUID *luid)
188 {
189         NTSTATUS status;
190         struct lsa_LookupPrivName r;
191
192         r.in.handle = handle;
193         r.in.luid = luid;
194
195         status = dcerpc_lsa_LookupPrivName(p, mem_ctx, &r);
196         if (!NT_STATUS_IS_OK(status)) {
197                 printf("\nLookupPrivName failed - %s\n", nt_errstr(status));
198                 return False;
199         }
200
201         return True;
202 }
203
204 static BOOL test_EnumPrivsAccount(struct dcerpc_pipe *p, 
205                                   TALLOC_CTX *mem_ctx,                            
206                                   struct policy_handle *handle,
207                                   struct policy_handle *acct_handle)
208 {
209         NTSTATUS status;
210         struct lsa_EnumPrivsAccount r;
211
212         printf("Testing EnumPrivsAccount\n");
213
214         r.in.handle = acct_handle;
215
216         status = dcerpc_lsa_EnumPrivsAccount(p, mem_ctx, &r);
217         if (!NT_STATUS_IS_OK(status)) {
218                 printf("EnumPrivsAccount failed - %s\n", nt_errstr(status));
219                 return False;
220         }
221
222         if (r.out.privs) {
223                 int i;
224                 for (i=0;i<r.out.privs->count;i++) {
225                         test_LookupPrivName(p, mem_ctx, handle, 
226                                             &r.out.privs->set[i].luid);
227                 }
228         }
229
230         return True;
231 }
232
233 static BOOL test_Delete(struct dcerpc_pipe *p, 
234                        TALLOC_CTX *mem_ctx, 
235                        struct policy_handle *handle)
236 {
237         NTSTATUS status;
238         struct lsa_Delete r;
239
240         printf("\ntesting Delete\n");
241
242         r.in.handle = handle;
243         status = dcerpc_lsa_Delete(p, mem_ctx, &r);
244         if (!NT_STATUS_IS_OK(status)) {
245                 printf("Delete failed - %s\n", nt_errstr(status));
246                 return False;
247         }
248
249         printf("\n");
250
251         return True;
252 }
253
254
255 static BOOL test_CreateAccount(struct dcerpc_pipe *p, 
256                                TALLOC_CTX *mem_ctx, 
257                                struct policy_handle *handle)
258 {
259         NTSTATUS status;
260         struct lsa_CreateAccount r;
261         struct dom_sid2 *newsid;
262         struct policy_handle acct_handle;
263
264         newsid = dom_sid_parse_talloc(mem_ctx, "S-1-5-12349876-4321-2854");
265
266         printf("Testing CreateAccount\n");
267
268         r.in.handle = handle;
269         r.in.sid = newsid;
270         r.in.desired_access = SEC_RIGHTS_MAXIMUM_ALLOWED;
271         r.out.acct_handle = &acct_handle;
272
273         status = dcerpc_lsa_CreateAccount(p, mem_ctx, &r);
274         if (!NT_STATUS_IS_OK(status)) {
275                 printf("CreateAccount failed - %s\n", nt_errstr(status));
276                 return False;
277         }
278
279         if (!test_Delete(p, mem_ctx, &acct_handle)) {
280                 return False;
281         }
282
283         return True;
284 }
285
286
287 static BOOL test_CreateTrustedDomain(struct dcerpc_pipe *p, 
288                                      TALLOC_CTX *mem_ctx, 
289                                      struct policy_handle *handle)
290 {
291         NTSTATUS status;
292         struct lsa_CreateTrustedDomain r;
293         struct lsa_TrustInformation trustinfo;
294         struct dom_sid *domsid;
295         struct policy_handle dom_handle;
296
297         printf("Testing CreateTrustedDomain\n");
298
299         domsid = dom_sid_parse_talloc(mem_ctx, "S-1-5-697-97398-3797956");
300
301         trustinfo.sid = domsid;
302         init_lsa_Name(&trustinfo.name, "torturedomain");
303
304         r.in.handle = handle;
305         r.in.info = &trustinfo;
306         r.in.desired_access = SEC_RIGHTS_MAXIMUM_ALLOWED;
307         r.out.dom_handle = &dom_handle;
308
309         status = dcerpc_lsa_CreateTrustedDomain(p, mem_ctx, &r);
310         if (!NT_STATUS_IS_OK(status)) {
311                 printf("CreateTrustedDomain failed - %s\n", nt_errstr(status));
312                 return False;
313         }
314
315         if (!test_Delete(p, mem_ctx, &dom_handle)) {
316                 return False;
317         }
318
319         return True;
320 }
321
322 static BOOL test_CreateSecret(struct dcerpc_pipe *p, 
323                               TALLOC_CTX *mem_ctx, 
324                               struct policy_handle *handle)
325 {
326         NTSTATUS status;
327         struct lsa_CreateSecret r;
328         struct lsa_OpenSecret r2;
329         struct lsa_SetSecret r3;
330         struct lsa_QuerySecret r4;
331         struct policy_handle sec_handle, sec_handle2;
332         struct lsa_Delete d;
333         struct lsa_DATA_BUF buf1;
334         struct lsa_DATA_BUF_PTR bufp1;
335         DATA_BLOB enc_key;
336         BOOL ret = True;
337         DATA_BLOB session_key;
338         NTTIME old_mtime, new_mtime;
339         DATA_BLOB blob1, blob2;
340         const char *secret1 = "abcdef12345699qwerty";
341         char *secret2;
342         char *secname;
343
344         printf("Testing CreateSecret\n");
345
346         asprintf(&secname, "torturesecret-%u", (unsigned)random());
347
348         init_lsa_Name(&r.in.name, secname);
349
350         r.in.handle = handle;
351         r.in.desired_access = SEC_RIGHTS_MAXIMUM_ALLOWED;
352         r.out.sec_handle = &sec_handle;
353
354         status = dcerpc_lsa_CreateSecret(p, mem_ctx, &r);
355         if (!NT_STATUS_IS_OK(status)) {
356                 printf("CreateSecret failed - %s\n", nt_errstr(status));
357                 return False;
358         }
359
360         r2.in.handle = handle;
361         r2.in.desired_access = SEC_RIGHTS_MAXIMUM_ALLOWED;
362         r2.in.name = r.in.name;
363         r2.out.sec_handle = &sec_handle2;
364
365         printf("Testing OpenSecret\n");
366
367         status = dcerpc_lsa_OpenSecret(p, mem_ctx, &r2);
368         if (!NT_STATUS_IS_OK(status)) {
369                 printf("OpenSecret failed - %s\n", nt_errstr(status));
370                 ret = False;
371         }
372
373         status = dcerpc_fetch_session_key(p, &session_key);
374         if (!NT_STATUS_IS_OK(status)) {
375                 printf("dcerpc_fetch_session_key failed - %s\n", nt_errstr(status));
376                 ret = False;
377         }
378
379         enc_key = sess_encrypt_string(secret1, &session_key);
380
381         r3.in.handle = &sec_handle;
382         r3.in.new_val = &buf1;
383         r3.in.old_val = NULL;
384         r3.in.new_val->data = enc_key.data;
385         r3.in.new_val->length = enc_key.length;
386         r3.in.new_val->size = enc_key.length;
387
388         printf("Testing SetSecret\n");
389
390         status = dcerpc_lsa_SetSecret(p, mem_ctx, &r3);
391         if (!NT_STATUS_IS_OK(status)) {
392                 printf("SetSecret failed - %s\n", nt_errstr(status));
393                 ret = False;
394         }
395
396         data_blob_free(&enc_key);
397
398         ZERO_STRUCT(new_mtime);
399         ZERO_STRUCT(old_mtime);
400
401         /* fetch the secret back again */
402         r4.in.handle = &sec_handle;
403         r4.in.new_val = &bufp1;
404         r4.in.new_mtime = &new_mtime;
405         r4.in.old_val = NULL;
406         r4.in.old_mtime = NULL;
407
408         bufp1.buf = NULL;
409
410         status = dcerpc_lsa_QuerySecret(p, mem_ctx, &r4);
411         if (!NT_STATUS_IS_OK(status)) {
412                 printf("QuerySecret failed - %s\n", nt_errstr(status));
413                 ret = False;
414         }
415
416         blob1.data = r4.out.new_val->buf->data;
417         blob1.length = r4.out.new_val->buf->length;
418
419         blob2 = data_blob(NULL, blob1.length);
420
421         secret2 = sess_decrypt_string(&blob1, &session_key);
422
423         printf("returned secret '%s'\n", secret2);
424
425         if (strcmp(secret1, secret2) != 0) {
426                 printf("Returned secret doesn't match\n");
427                 ret = False;
428         }
429
430         if (!test_Delete(p, mem_ctx, &sec_handle)) {
431                 ret = False;
432         }
433
434         d.in.handle = &sec_handle2;
435         status = dcerpc_lsa_Delete(p, mem_ctx, &d);
436         if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_HANDLE)) {
437                 printf("Second delete expected INVALID_HANDLE - %s\n", nt_errstr(status));
438                 ret = False;
439         }
440
441         return ret;
442 }
443
444 static BOOL test_EnumAccountRights(struct dcerpc_pipe *p, 
445                                    TALLOC_CTX *mem_ctx, 
446                                    struct policy_handle *acct_handle,
447                                    struct dom_sid *sid)
448 {
449         NTSTATUS status;
450         struct lsa_EnumAccountRights r;
451         struct lsa_RightSet rights;
452
453         printf("Testing EnumAccountRights\n");
454
455         r.in.handle = acct_handle;
456         r.in.sid = sid;
457         r.out.rights = &rights;
458
459         status = dcerpc_lsa_EnumAccountRights(p, mem_ctx, &r);
460         if (!NT_STATUS_IS_OK(status)) {
461                 printf("EnumAccountRights failed - %s\n", nt_errstr(status));
462                 return False;
463         }
464
465         return True;
466 }
467
468
469 static BOOL test_QuerySecObj(struct dcerpc_pipe *p, 
470                              TALLOC_CTX *mem_ctx, 
471                              struct policy_handle *handle,
472                              struct policy_handle *acct_handle)
473 {
474         NTSTATUS status;
475         struct lsa_QuerySecObj r;
476
477         printf("Testing QuerySecObj\n");
478
479         r.in.handle = acct_handle;
480         r.in.sec_info = 7;
481
482         status = dcerpc_lsa_QuerySecObj(p, mem_ctx, &r);
483         if (!NT_STATUS_IS_OK(status)) {
484                 printf("QuerySecObj failed - %s\n", nt_errstr(status));
485                 return False;
486         }
487
488         return True;
489 }
490
491 static BOOL test_OpenAccount(struct dcerpc_pipe *p, 
492                              TALLOC_CTX *mem_ctx, 
493                              struct policy_handle *handle,
494                              struct dom_sid *sid)
495 {
496         NTSTATUS status;
497         struct lsa_OpenAccount r;
498         struct policy_handle acct_handle;
499
500         printf("Testing OpenAccount\n");
501
502         r.in.handle = handle;
503         r.in.sid = sid;
504         r.in.desired_access = SEC_RIGHTS_MAXIMUM_ALLOWED;
505         r.out.acct_handle = &acct_handle;
506
507         status = dcerpc_lsa_OpenAccount(p, mem_ctx, &r);
508         if (!NT_STATUS_IS_OK(status)) {
509                 printf("OpenAccount failed - %s\n", nt_errstr(status));
510                 return False;
511         }
512
513         if (!test_EnumPrivsAccount(p, mem_ctx, handle, &acct_handle)) {
514                 return False;
515         }
516
517         if (!test_QuerySecObj(p, mem_ctx, handle, &acct_handle)) {
518                 return False;
519         }
520
521         return True;
522 }
523
524 static BOOL test_EnumAccounts(struct dcerpc_pipe *p, 
525                           TALLOC_CTX *mem_ctx, 
526                           struct policy_handle *handle)
527 {
528         NTSTATUS status;
529         struct lsa_EnumAccounts r;
530         struct lsa_SidArray sids1, sids2;
531         uint32_t resume_handle = 0;
532         int i;
533
534         printf("\ntesting EnumAccounts\n");
535
536         r.in.handle = handle;
537         r.in.resume_handle = &resume_handle;
538         r.in.num_entries = 100;
539         r.out.resume_handle = &resume_handle;
540         r.out.sids = &sids1;
541
542         resume_handle = 0;
543         status = dcerpc_lsa_EnumAccounts(p, mem_ctx, &r);
544         if (!NT_STATUS_IS_OK(status)) {
545                 printf("EnumAccounts failed - %s\n", nt_errstr(status));
546                 return False;
547         }
548
549         if (!test_LookupSids(p, mem_ctx, handle, &sids1)) {
550                 return False;
551         }
552
553         printf("testing all accounts\n");
554         for (i=0;i<sids1.num_sids;i++) {
555                 test_OpenAccount(p, mem_ctx, handle, sids1.sids[i].sid);
556                 test_EnumAccountRights(p, mem_ctx, handle, sids1.sids[i].sid);
557         }
558         printf("\n");
559
560         if (sids1.num_sids < 3) {
561                 return True;
562         }
563         
564         printf("trying EnumAccounts partial listing (asking for 1 at 2)\n");
565         resume_handle = 2;
566         r.in.num_entries = 1;
567         r.out.sids = &sids2;
568
569         status = dcerpc_lsa_EnumAccounts(p, mem_ctx, &r);
570         if (!NT_STATUS_IS_OK(status)) {
571                 printf("EnumAccounts failed - %s\n", nt_errstr(status));
572                 return False;
573         }
574
575         if (sids2.num_sids != 1) {
576                 printf("Returned wrong number of entries (%d)\n", sids2.num_sids);
577                 return False;
578         }
579
580         return True;
581 }
582
583
584 static BOOL test_EnumPrivs(struct dcerpc_pipe *p, 
585                            TALLOC_CTX *mem_ctx, 
586                            struct policy_handle *handle)
587 {
588         NTSTATUS status;
589         struct lsa_EnumPrivs r;
590         struct lsa_PrivArray privs1;
591         uint32_t resume_handle = 0;
592
593         printf("\ntesting EnumPrivs\n");
594
595         r.in.handle = handle;
596         r.in.resume_handle = &resume_handle;
597         r.in.max_count = 1000;
598         r.out.resume_handle = &resume_handle;
599         r.out.privs = &privs1;
600
601         resume_handle = 0;
602         status = dcerpc_lsa_EnumPrivs(p, mem_ctx, &r);
603         if (!NT_STATUS_IS_OK(status)) {
604                 printf("EnumPrivs failed - %s\n", nt_errstr(status));
605                 return False;
606         }
607
608         return True;
609 }
610
611
612 static BOOL test_EnumTrustDom(struct dcerpc_pipe *p, 
613                               TALLOC_CTX *mem_ctx, 
614                               struct policy_handle *handle)
615 {
616         struct lsa_EnumTrustDom r;
617         NTSTATUS status;
618         uint32_t resume_handle = 0;
619         struct lsa_DomainList domains;
620
621         printf("\nTesting EnumTrustDom\n");
622
623         r.in.handle = handle;
624         r.in.resume_handle = &resume_handle;
625         r.in.num_entries = 1000;
626         r.out.domains = &domains;
627         r.out.resume_handle = &resume_handle;
628
629         status = dcerpc_lsa_EnumTrustDom(p, mem_ctx, &r);
630
631         /* NO_MORE_ENTRIES is allowed */
632         if (NT_STATUS_EQUAL(status, NT_STATUS_NO_MORE_ENTRIES)) {
633                 return True;
634         }
635
636         if (!NT_STATUS_IS_OK(status)) {
637                 printf("EnumTrustDom failed - %s\n", nt_errstr(status));
638                 return False;
639         }
640
641         return True;
642 }
643
644 static BOOL test_QueryInfoPolicy(struct dcerpc_pipe *p, 
645                                  TALLOC_CTX *mem_ctx, 
646                                  struct policy_handle *handle)
647 {
648         struct lsa_QueryInfoPolicy r;
649         NTSTATUS status;
650         int i;
651         BOOL ret = True;
652         printf("\nTesting QueryInfoPolicy\n");
653
654         for (i=1;i<13;i++) {
655                 r.in.handle = handle;
656                 r.in.level = i;
657
658                 printf("\ntrying QueryInfoPolicy level %d\n", i);
659
660                 status = dcerpc_lsa_QueryInfoPolicy(p, mem_ctx, &r);
661
662                 if ((i == 9 || i == 10 || i == 11) &&
663                     NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER)) {
664                         printf("server failed level %u (OK)\n", i);
665                         continue;
666                 }
667
668                 if (!NT_STATUS_IS_OK(status)) {
669                         printf("QueryInfoPolicy failed - %s\n", nt_errstr(status));
670                         ret = False;
671                         continue;
672                 }
673         }
674
675         return ret;
676 }
677
678 static BOOL test_Close(struct dcerpc_pipe *p, 
679                        TALLOC_CTX *mem_ctx, 
680                        struct policy_handle *handle)
681 {
682         NTSTATUS status;
683         struct lsa_Close r;
684         struct policy_handle handle2;
685
686         printf("\ntesting Close\n");
687
688         r.in.handle = handle;
689         r.out.handle = &handle2;
690
691         status = dcerpc_lsa_Close(p, mem_ctx, &r);
692         if (!NT_STATUS_IS_OK(status)) {
693                 printf("Close failed - %s\n", nt_errstr(status));
694                 return False;
695         }
696
697         status = dcerpc_lsa_Close(p, mem_ctx, &r);
698         /* its really a fault - we need a status code for rpc fault */
699         if (!NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) {
700                 printf("Close failed - %s\n", nt_errstr(status));
701                 return False;
702         }
703
704         printf("\n");
705
706         return True;
707 }
708
709 BOOL torture_rpc_lsa(int dummy)
710 {
711         NTSTATUS status;
712         struct dcerpc_pipe *p;
713         TALLOC_CTX *mem_ctx;
714         BOOL ret = True;
715         struct policy_handle handle;
716
717         mem_ctx = talloc_init("torture_rpc_lsa");
718
719         status = torture_rpc_connection(&p, 
720                                         DCERPC_LSARPC_NAME, 
721                                         DCERPC_LSARPC_UUID, 
722                                         DCERPC_LSARPC_VERSION);
723         if (!NT_STATUS_IS_OK(status)) {
724                 return False;
725         }
726
727         if (!test_OpenPolicy(p, mem_ctx)) {
728                 ret = False;
729         }
730
731         if (!test_OpenPolicy2(p, mem_ctx, &handle)) {
732                 ret = False;
733         }
734
735         if (!test_CreateAccount(p, mem_ctx, &handle)) {
736                 ret = False;
737         }
738
739         if (!test_CreateSecret(p, mem_ctx, &handle)) {
740                 ret = False;
741         }
742
743         if (!test_CreateTrustedDomain(p, mem_ctx, &handle)) {
744                 ret = False;
745         }
746
747         if (!test_EnumAccounts(p, mem_ctx, &handle)) {
748                 ret = False;
749         }
750
751         if (!test_EnumPrivs(p, mem_ctx, &handle)) {
752                 ret = False;
753         }
754
755         if (!test_EnumTrustDom(p, mem_ctx, &handle)) {
756                 ret = False;
757         }
758
759         if (!test_QueryInfoPolicy(p, mem_ctx, &handle)) {
760                 ret = False;
761         }
762         
763 #if 0
764         if (!test_Delete(p, mem_ctx, &handle)) {
765                 ret = False;
766         }
767 #endif
768         
769         if (!test_Close(p, mem_ctx, &handle)) {
770                 ret = False;
771         }
772
773         talloc_destroy(mem_ctx);
774
775         torture_rpc_close(p);
776
777         return ret;
778 }