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