r23792: convert Samba4 to GPLv3
[bbaumbach/samba-autobuild/.git] / source4 / torture / libnet / libnet_user.c
1 /* 
2    Unix SMB/CIFS implementation.
3    Test suite for libnet calls.
4
5    Copyright (C) Rafal Szczesniak 2005
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 3 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, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include "includes.h"
22 #include "system/time.h"
23 #include "lib/cmdline/popt_common.h"
24 #include "libnet/libnet.h"
25 #include "librpc/gen_ndr/ndr_samr_c.h"
26 #include "librpc/gen_ndr/ndr_lsa_c.h"
27 #include "torture/torture.h"
28 #include "torture/rpc/rpc.h"
29 #include "torture/libnet/usertest.h"
30
31
32 static BOOL test_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
33                          struct policy_handle *domain_handle, const char *username)
34 {
35         NTSTATUS status;
36         struct samr_LookupNames r1;
37         struct samr_OpenUser r2;
38         struct samr_DeleteUser r3;
39         struct lsa_String names[2];
40         uint32_t rid;
41         struct policy_handle user_handle;
42
43         names[0].string = username;
44
45         r1.in.domain_handle  = domain_handle;
46         r1.in.num_names      = 1;
47         r1.in.names          = names;
48         
49         printf("user account lookup '%s'\n", username);
50
51         status = dcerpc_samr_LookupNames(p, mem_ctx, &r1);
52         if (!NT_STATUS_IS_OK(status)) {
53                 printf("LookupNames failed - %s\n", nt_errstr(status));
54                 return False;
55         }
56
57         rid = r1.out.rids.ids[0];
58         
59         r2.in.domain_handle  = domain_handle;
60         r2.in.access_mask    = SEC_FLAG_MAXIMUM_ALLOWED;
61         r2.in.rid            = rid;
62         r2.out.user_handle   = &user_handle;
63
64         printf("opening user account\n");
65
66         status = dcerpc_samr_OpenUser(p, mem_ctx, &r2);
67         if (!NT_STATUS_IS_OK(status)) {
68                 printf("OpenUser failed - %s\n", nt_errstr(status));
69                 return False;
70         }
71
72         r3.in.user_handle  = &user_handle;
73         r3.out.user_handle = &user_handle;
74
75         printf("deleting user account\n");
76         
77         status = dcerpc_samr_DeleteUser(p, mem_ctx, &r3);
78         if (!NT_STATUS_IS_OK(status)) {
79                 printf("DeleteUser failed - %s\n", nt_errstr(status));
80                 return False;
81         }
82
83         return True;
84 }
85
86
87 static BOOL test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
88                             struct policy_handle *handle, struct lsa_String *domname)
89 {
90         NTSTATUS status;
91         struct policy_handle h, domain_handle;
92         struct samr_Connect r1;
93         struct samr_LookupDomain r2;
94         struct samr_OpenDomain r3;
95         
96         printf("connecting\n");
97         
98         r1.in.system_name = 0;
99         r1.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
100         r1.out.connect_handle = &h;
101         
102         status = dcerpc_samr_Connect(p, mem_ctx, &r1);
103         if (!NT_STATUS_IS_OK(status)) {
104                 printf("Connect failed - %s\n", nt_errstr(status));
105                 return False;
106         }
107         
108         r2.in.connect_handle = &h;
109         r2.in.domain_name = domname;
110
111         printf("domain lookup on %s\n", domname->string);
112
113         status = dcerpc_samr_LookupDomain(p, mem_ctx, &r2);
114         if (!NT_STATUS_IS_OK(status)) {
115                 printf("LookupDomain failed - %s\n", nt_errstr(status));
116                 return False;
117         }
118
119         r3.in.connect_handle = &h;
120         r3.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
121         r3.in.sid = r2.out.sid;
122         r3.out.domain_handle = &domain_handle;
123
124         printf("opening domain\n");
125
126         status = dcerpc_samr_OpenDomain(p, mem_ctx, &r3);
127         if (!NT_STATUS_IS_OK(status)) {
128                 printf("OpenDomain failed - %s\n", nt_errstr(status));
129                 return False;
130         } else {
131                 *handle = domain_handle;
132         }
133
134         return True;
135 }
136
137
138 static BOOL test_samr_close(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
139                             struct policy_handle *domain_handle)
140 {
141         NTSTATUS status;
142         struct samr_Close r;
143   
144         r.in.handle = domain_handle;
145         r.out.handle = domain_handle;
146
147         status = dcerpc_samr_Close(p, mem_ctx, &r);
148         if (!NT_STATUS_IS_OK(status)) {
149                 printf("Close samr domain failed - %s\n", nt_errstr(status));
150                 return False;
151         }
152         
153         return True;
154 }
155
156
157 static BOOL test_lsa_close(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
158                            struct policy_handle *domain_handle)
159 {
160         NTSTATUS status;
161         struct lsa_Close r;
162
163         r.in.handle = domain_handle;
164         r.out.handle = domain_handle;
165         
166         status = dcerpc_lsa_Close(p, mem_ctx, &r);
167         if (!NT_STATUS_IS_OK(status)) {
168                 printf("Close lsa domain failed - %s\n", nt_errstr(status));
169                 return False;
170         }
171
172         return True;
173 }
174
175
176 static BOOL test_createuser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
177                             struct policy_handle *handle, const char* user)
178 {
179         NTSTATUS status;
180         struct policy_handle user_handle;
181         struct lsa_String username;
182         struct samr_CreateUser r1;
183         struct samr_Close r2;
184         uint32_t user_rid;
185
186         username.string = user;
187         
188         r1.in.domain_handle = handle;
189         r1.in.account_name = &username;
190         r1.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
191         r1.out.user_handle = &user_handle;
192         r1.out.rid = &user_rid;
193
194         printf("creating user '%s'\n", username.string);
195         
196         status = dcerpc_samr_CreateUser(p, mem_ctx, &r1);
197         if (!NT_STATUS_IS_OK(status)) {
198                 printf("CreateUser failed - %s\n", nt_errstr(status));
199
200                 if (NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) {
201                         printf("User (%s) already exists - attempting to delete and recreate account again\n", user);
202                         if (!test_cleanup(p, mem_ctx, handle, TEST_USERNAME)) {
203                                 return False;
204                         }
205
206                         printf("creating user account\n");
207                         
208                         status = dcerpc_samr_CreateUser(p, mem_ctx, &r1);
209                         if (!NT_STATUS_IS_OK(status)) {
210                                 printf("CreateUser failed - %s\n", nt_errstr(status));
211                                 return False;
212                         }
213                         return True;
214                 }               
215                 return False;
216         }
217
218         r2.in.handle = &user_handle;
219         r2.out.handle = &user_handle;
220         
221         printf("closing user '%s'\n", username.string);
222
223         status = dcerpc_samr_Close(p, mem_ctx, &r2);
224         if (!NT_STATUS_IS_OK(status)) {
225                 printf("Close failed - %s\n", nt_errstr(status));
226                 return False;
227         }
228
229         return True;
230 }
231
232
233 BOOL torture_createuser(struct torture_context *torture)
234 {
235         NTSTATUS status;
236         const char *binding;
237         TALLOC_CTX *mem_ctx;
238         struct libnet_context *ctx;
239         struct libnet_CreateUser req;
240         BOOL ret = True;
241
242         mem_ctx = talloc_init("test_createuser");
243         binding = torture_setting_string(torture, "binding", NULL);
244
245         ctx = libnet_context_init(NULL);
246         ctx->cred = cmdline_credentials;
247
248         req.in.user_name = TEST_USERNAME;
249         req.in.domain_name = lp_workgroup();
250         req.out.error_string = NULL;
251
252         status = libnet_CreateUser(ctx, mem_ctx, &req);
253         if (!NT_STATUS_IS_OK(status)) {
254                 printf("libnet_CreateUser call failed: %s\n", nt_errstr(status));
255                 ret = False;
256                 goto done;
257         }
258
259         if (!test_cleanup(ctx->samr.pipe, mem_ctx, &ctx->samr.handle, TEST_USERNAME)) {
260                 printf("cleanup failed\n");
261                 ret = False;
262                 goto done;
263         }
264
265         if (!test_samr_close(ctx->samr.pipe, mem_ctx, &ctx->samr.handle)) {
266                 printf("domain close failed\n");
267                 ret = False;
268         }
269
270 done:
271         talloc_free(ctx);
272         talloc_free(mem_ctx);
273         return ret;
274 }
275
276
277 BOOL torture_deleteuser(struct torture_context *torture)
278 {
279         NTSTATUS status;
280         const char *binding;
281         struct dcerpc_pipe *p;
282         TALLOC_CTX *prep_mem_ctx, *mem_ctx;
283         struct policy_handle h;
284         struct lsa_String domain_name;
285         const char *name = TEST_USERNAME;
286         struct libnet_context *ctx;
287         struct libnet_DeleteUser req;
288         BOOL ret = True;
289
290         prep_mem_ctx = talloc_init("prepare test_deleteuser");
291         binding = torture_setting_string(torture, "binding", NULL);
292
293         ctx = libnet_context_init(NULL);
294         ctx->cred = cmdline_credentials;
295
296         req.in.user_name = TEST_USERNAME;
297         req.in.domain_name = lp_workgroup();
298
299         status = torture_rpc_connection(prep_mem_ctx,
300                                         &p,
301                                         &dcerpc_table_samr);
302         if (!NT_STATUS_IS_OK(status)) {
303                 ret = False;
304                 goto done;
305         }
306
307         domain_name.string = lp_workgroup();
308         if (!test_opendomain(p, prep_mem_ctx, &h, &domain_name)) {
309                 ret = False;
310                 goto done;
311         }
312
313         if (!test_createuser(p, prep_mem_ctx, &h, name)) {
314                 ret = False;
315                 goto done;
316         }
317
318         mem_ctx = talloc_init("test_deleteuser");
319
320         status = libnet_DeleteUser(ctx, mem_ctx, &req);
321         if (!NT_STATUS_IS_OK(status)) {
322                 printf("libnet_DeleteUser call failed: %s\n", nt_errstr(status));
323                 ret = False;
324         }
325
326         talloc_free(mem_ctx);
327
328 done:
329         talloc_free(ctx);
330         talloc_free(prep_mem_ctx);
331         return ret;
332 }
333
334
335 /*
336   Generate testing set of random changes
337 */
338
339 static void set_test_changes(TALLOC_CTX *mem_ctx, struct libnet_ModifyUser *r,
340                              int num_changes, char **user_name, enum test_fields req_change)
341 {
342         const char* logon_scripts[] = { "start_login.cmd", "login.bat", "start.cmd" };
343         const char* home_dirs[] = { "\\\\srv\\home", "\\\\homesrv\\home\\user", "\\\\pdcsrv\\domain" };
344         const char* home_drives[] = { "H:", "z:", "I:", "J:", "n:" };
345         const char *homedir, *homedrive, *logonscript;
346         struct timeval now;
347         int i, testfld;
348
349         srandom((unsigned)time(NULL));
350
351         printf("Fields to change: [");
352
353         for (i = 0; i < num_changes && i < FIELDS_NUM; i++) {
354                 const char *fldname;
355
356                 testfld = (req_change == none) ? (random() % FIELDS_NUM) : req_change;
357
358                 /* get one in case we hit time field this time */
359                 gettimeofday(&now, NULL);
360                 
361                 switch (testfld) {
362                 case account_name:
363                         continue_if_field_set(r->in.account_name);
364                         r->in.account_name = talloc_asprintf(mem_ctx, TEST_CHG_ACCOUNTNAME,
365                                                              (int)(random() % 100));
366                         fldname = "account_name";
367                         
368                         /* update the test's user name in case it's about to change */
369                         *user_name = talloc_strdup(mem_ctx, r->in.account_name);
370                         break;
371
372                 case full_name:
373                         continue_if_field_set(r->in.full_name);
374                         r->in.full_name = talloc_asprintf(mem_ctx, TEST_CHG_FULLNAME,
375                                                           (unsigned int)random(), (unsigned int)random());
376                         fldname = "full_name";
377                         break;
378
379                 case description:
380                         continue_if_field_set(r->in.description);
381                         r->in.description = talloc_asprintf(mem_ctx, TEST_CHG_DESCRIPTION,
382                                                             (long)random());
383                         fldname = "description";
384                         break;
385
386                 case home_directory:
387                         continue_if_field_set(r->in.home_directory);
388                         homedir = home_dirs[random() % (sizeof(home_dirs)/sizeof(char*))];
389                         r->in.home_directory = talloc_strdup(mem_ctx, homedir);
390                         fldname = "home_dir";
391                         break;
392
393                 case home_drive:
394                         continue_if_field_set(r->in.home_drive);
395                         homedrive = home_drives[random() % (sizeof(home_drives)/sizeof(char*))];
396                         r->in.home_drive = talloc_strdup(mem_ctx, homedrive);
397                         fldname = "home_drive";
398                         break;
399
400                 case comment:
401                         continue_if_field_set(r->in.comment);
402                         r->in.comment = talloc_asprintf(mem_ctx, TEST_CHG_COMMENT,
403                                                         (unsigned long)random(), (unsigned long)random());
404                         fldname = "comment";
405                         break;
406
407                 case logon_script:
408                         continue_if_field_set(r->in.logon_script);
409                         logonscript = logon_scripts[random() % (sizeof(logon_scripts)/sizeof(char*))];
410                         r->in.logon_script = talloc_strdup(mem_ctx, logonscript);
411                         fldname = "logon_script";
412                         break;
413                         
414                 case profile_path:
415                         continue_if_field_set(r->in.profile_path);
416                         r->in.profile_path = talloc_asprintf(mem_ctx, TEST_CHG_PROFILEPATH,
417                                                              (unsigned long)random(), (unsigned int)random());
418                         fldname = "profile_path";
419                         break;
420
421                 case acct_expiry:
422                         continue_if_field_set(r->in.acct_expiry);
423                         now = timeval_add(&now, (random() % (31*24*60*60)), 0);
424                         r->in.acct_expiry = talloc_memdup(mem_ctx, &now, sizeof(now));
425                         fldname = "acct_expiry";
426                         break;
427
428                 default:
429                         fldname = "unknown_field";
430                 }
431                 
432                 printf(((i < num_changes - 1) ? "%s," : "%s"), fldname);
433
434                 /* disable requested field (it's supposed to be the only one used) */
435                 if (req_change != none) req_change = none;
436         }
437
438         printf("]\n");
439 }
440
441
442 #define TEST_STR_FLD(fld) \
443         if (!strequal(req.in.fld, user_req.out.fld)) { \
444                 printf("failed to change '%s'\n", #fld); \
445                 ret = False; \
446                 goto cleanup; \
447         }
448
449 #define TEST_TIME_FLD(fld) \
450         if (timeval_compare(req.in.fld, user_req.out.fld)) { \
451                 printf("failed to change '%s'\n", #fld); \
452                 ret = False; \
453                 goto cleanup; \
454         }
455
456 #define TEST_NUM_FLD(fld) \
457         if (req.in.fld != user_req.out.fld) { \
458                 printf("failed to change '%s'\n", #fld); \
459                 ret = False; \
460                 goto cleanup; \
461         }
462
463
464 BOOL torture_modifyuser(struct torture_context *torture)
465 {
466         NTSTATUS status;
467         const char *binding;
468         struct dcerpc_binding *bind;
469         struct dcerpc_pipe *p;
470         TALLOC_CTX *prep_mem_ctx, *mem_ctx;
471         struct policy_handle h;
472         struct lsa_String domain_name;
473         char *name;
474         struct libnet_context *ctx;
475         struct libnet_ModifyUser req;
476         struct libnet_UserInfo user_req;
477         int fld;
478         BOOL ret = True;
479
480         prep_mem_ctx = talloc_init("prepare test_deleteuser");
481         binding = torture_setting_string(torture, "binding", NULL);
482
483         ctx = libnet_context_init(NULL);
484         ctx->cred = cmdline_credentials;
485
486         status = torture_rpc_connection(prep_mem_ctx,
487                                         &p,
488                                         &dcerpc_table_samr);
489         if (!NT_STATUS_IS_OK(status)) {
490                 ret = False;
491                 goto done;
492         }
493
494         name = talloc_strdup(prep_mem_ctx, TEST_USERNAME);
495
496         domain_name.string = lp_workgroup();
497         if (!test_opendomain(p, prep_mem_ctx, &h, &domain_name)) {
498                 ret = False;
499                 goto done;
500         }
501
502         if (!test_createuser(p, prep_mem_ctx, &h, name)) {
503                 ret = False;
504                 goto done;
505         }
506
507         mem_ctx = talloc_init("test_modifyuser");
508
509         status = dcerpc_parse_binding(mem_ctx, binding, &bind);
510         if (!NT_STATUS_IS_OK(status)) {
511                 ret = False;
512                 goto done;
513         }
514
515         printf("Testing change of all fields - each single one in turn\n");
516
517         for (fld = 1; fld < FIELDS_NUM - 1; fld++) {
518                 ZERO_STRUCT(req);
519                 req.in.domain_name = lp_workgroup();
520                 req.in.user_name = name;
521
522                 set_test_changes(mem_ctx, &req, 1, &name, fld);
523
524                 status = libnet_ModifyUser(ctx, mem_ctx, &req);
525                 if (!NT_STATUS_IS_OK(status)) {
526                         printf("libnet_ModifyUser call failed: %s\n", nt_errstr(status));
527                         ret = False;
528                         continue;
529                 }
530
531                 ZERO_STRUCT(user_req);
532                 user_req.in.domain_name = lp_workgroup();
533                 user_req.in.user_name = name;
534
535                 status = libnet_UserInfo(ctx, mem_ctx, &user_req);
536                 if (!NT_STATUS_IS_OK(status)) {
537                         printf("libnet_UserInfo call failed: %s\n", nt_errstr(status));
538                         ret = False;
539                         continue;
540                 }
541
542                 switch (fld) {
543                 case account_name: TEST_STR_FLD(account_name);
544                         break;
545                 case full_name: TEST_STR_FLD(full_name);
546                         break;
547                 case comment: TEST_STR_FLD(comment);
548                         break;
549                 case description: TEST_STR_FLD(description);
550                         break;
551                 case home_directory: TEST_STR_FLD(home_directory);
552                         break;
553                 case home_drive: TEST_STR_FLD(home_drive);
554                         break;
555                 case logon_script: TEST_STR_FLD(logon_script);
556                         break;
557                 case profile_path: TEST_STR_FLD(profile_path);
558                         break;
559                 case acct_expiry: TEST_TIME_FLD(acct_expiry);
560                         break;
561                 case acct_flags: TEST_NUM_FLD(acct_flags);
562                         break;
563                 default:
564                         break;
565                 }
566
567                 if (fld == account_name) {
568                         /* restore original testing username - it's useful when test fails
569                            because it prevents from problems with recreating account */
570                         ZERO_STRUCT(req);
571                         req.in.domain_name = lp_workgroup();
572                         req.in.user_name = name;
573                         req.in.account_name = TEST_USERNAME;
574                         
575                         status = libnet_ModifyUser(ctx, mem_ctx, &req);
576                         if (!NT_STATUS_IS_OK(status)) {
577                                 printf("libnet_ModifyUser call failed: %s\n", nt_errstr(status));
578                                 talloc_free(mem_ctx);
579                                 ret = False;
580                                 goto done;
581                         }
582                         
583                         name = talloc_strdup(mem_ctx, TEST_USERNAME);
584                 }
585         }
586
587 cleanup:
588         if (!test_cleanup(ctx->samr.pipe, mem_ctx, &ctx->samr.handle, name)) {
589                 printf("cleanup failed\n");
590                 ret = False;
591                 goto done;
592         }
593
594         if (!test_samr_close(ctx->samr.pipe, mem_ctx, &ctx->samr.handle)) {
595                 printf("domain close failed\n");
596                 ret = False;
597         }
598
599         talloc_free(mem_ctx);
600
601 done:
602         talloc_free(ctx);
603         talloc_free(prep_mem_ctx);
604         return ret;
605 }
606
607
608 BOOL torture_userinfo_api(struct torture_context *torture)
609 {
610         const char *name = TEST_USERNAME;
611         const char *binding;
612         BOOL ret = True;
613         NTSTATUS status;
614         TALLOC_CTX *mem_ctx = NULL, *prep_mem_ctx;
615         struct libnet_context *ctx;
616         struct dcerpc_pipe *p;
617         struct policy_handle h;
618         struct lsa_String domain_name;
619         struct libnet_UserInfo req;
620
621         prep_mem_ctx = talloc_init("prepare torture user info");
622         binding = torture_setting_string(torture, "binding", NULL);
623
624         ctx = libnet_context_init(NULL);
625         ctx->cred = cmdline_credentials;
626
627         status = torture_rpc_connection(prep_mem_ctx,
628                                         &p,
629                                         &dcerpc_table_samr);
630         if (!NT_STATUS_IS_OK(status)) {
631                 return False;
632         }
633
634         domain_name.string = lp_workgroup();
635         if (!test_opendomain(p, prep_mem_ctx, &h, &domain_name)) {
636                 ret = False;
637                 goto done;
638         }
639
640         if (!test_createuser(p, prep_mem_ctx, &h, name)) {
641                 ret = False;
642                 goto done;
643         }
644
645         mem_ctx = talloc_init("torture user info");
646
647         ZERO_STRUCT(req);
648         
649         req.in.domain_name = domain_name.string;
650         req.in.user_name   = name;
651
652         status = libnet_UserInfo(ctx, mem_ctx, &req);
653         if (!NT_STATUS_IS_OK(status)) {
654                 printf("libnet_UserInfo call failed: %s\n", nt_errstr(status));
655                 ret = False;
656                 talloc_free(mem_ctx);
657                 goto done;
658         }
659
660         if (!test_cleanup(ctx->samr.pipe, mem_ctx, &ctx->samr.handle, TEST_USERNAME)) {
661                 printf("cleanup failed\n");
662                 ret = False;
663                 goto done;
664         }
665
666         if (!test_samr_close(ctx->samr.pipe, mem_ctx, &ctx->samr.handle)) {
667                 printf("domain close failed\n");
668                 ret = False;
669         }
670
671         talloc_free(ctx);
672
673 done:
674         talloc_free(mem_ctx);
675         return ret;
676 }
677
678
679 BOOL torture_userlist(struct torture_context *torture)
680 {
681         const char *binding;
682         BOOL ret = True;
683         NTSTATUS status;
684         TALLOC_CTX *mem_ctx = NULL;
685         struct libnet_context *ctx;
686         struct lsa_String domain_name;
687         struct libnet_UserList req;
688         int i;
689
690         binding = torture_setting_string(torture, "binding", NULL);
691
692         ctx = libnet_context_init(NULL);
693         ctx->cred = cmdline_credentials;
694
695         domain_name.string = lp_workgroup();
696         mem_ctx = talloc_init("torture user list");
697
698         ZERO_STRUCT(req);
699
700         printf("listing user accounts:\n");
701         
702         do {
703
704                 req.in.domain_name = domain_name.string;
705                 req.in.page_size   = 128;
706                 req.in.resume_index = req.out.resume_index;
707
708                 status = libnet_UserList(ctx, mem_ctx, &req);
709
710                 for (i = 0; i < req.out.count; i++) {
711                         printf("\tuser: %s, sid=%s\n",
712                                req.out.users[i].username, req.out.users[i].sid);
713                 }
714
715         } while (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES));
716
717         if (!(NT_STATUS_IS_OK(status) ||
718               NT_STATUS_EQUAL(status, NT_STATUS_NO_MORE_ENTRIES))) {
719                 printf("libnet_UserList call failed: %s\n", nt_errstr(status));
720                 ret = False;
721                 goto done;
722         }
723
724         if (!test_samr_close(ctx->samr.pipe, mem_ctx, &ctx->samr.handle)) {
725                 printf("samr domain close failed\n");
726                 ret = False;
727                 goto done;
728         }
729
730         if (!test_lsa_close(ctx->lsa.pipe, mem_ctx, &ctx->lsa.handle)) {
731                 printf("lsa domain close failed\n");
732                 ret = False;
733         }
734
735         talloc_free(ctx);
736
737 done:
738         talloc_free(mem_ctx);
739         return ret;
740 }