s3-rpc_client: Move client pipe functions to own header.
[Samba/gebeck_regimport.git] / source3 / rpcclient / cmd_lsarpc.c
blob02aa07992e2e42eaf9f81790901878b382b75e57
1 /*
2 Unix SMB/CIFS implementation.
3 RPC pipe client
5 Copyright (C) Tim Potter 2000
6 Copyright (C) Rafal Szczesniak 2002
7 Copyright (C) Guenther Deschner 2008
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 #include "includes.h"
24 #include "rpcclient.h"
25 #include "rpc_client/cli_pipe.h"
26 #include "../libcli/auth/libcli_auth.h"
27 #include "../librpc/gen_ndr/ndr_lsa.h"
28 #include "../librpc/gen_ndr/ndr_lsa_c.h"
29 #include "rpc_client/cli_lsarpc.h"
30 #include "rpc_client/init_lsa.h"
31 #include "../libcli/security/security.h"
33 /* useful function to allow entering a name instead of a SID and
34 * looking it up automatically */
35 static NTSTATUS name_to_sid(struct rpc_pipe_client *cli,
36 TALLOC_CTX *mem_ctx,
37 struct dom_sid *sid, const char *name)
39 struct policy_handle pol;
40 enum lsa_SidType *sid_types;
41 NTSTATUS status, result;
42 struct dom_sid *sids;
43 struct dcerpc_binding_handle *b = cli->binding_handle;
45 /* maybe its a raw SID */
46 if (strncmp(name, "S-", 2) == 0 &&
47 string_to_sid(sid, name)) {
48 return NT_STATUS_OK;
51 status = rpccli_lsa_open_policy(cli, mem_ctx, True,
52 SEC_FLAG_MAXIMUM_ALLOWED,
53 &pol);
54 if (!NT_STATUS_IS_OK(status))
55 goto done;
57 status = rpccli_lsa_lookup_names(cli, mem_ctx, &pol, 1, &name, NULL, 1, &sids, &sid_types);
58 if (!NT_STATUS_IS_OK(status))
59 goto done;
61 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
63 *sid = sids[0];
65 done:
66 return status;
69 static void display_query_info_1(struct lsa_AuditLogInfo *r)
71 d_printf("percent_full:\t%d\n", r->percent_full);
72 d_printf("maximum_log_size:\t%d\n", r->maximum_log_size);
73 d_printf("retention_time:\t%lld\n", (long long)r->retention_time);
74 d_printf("shutdown_in_progress:\t%d\n", r->shutdown_in_progress);
75 d_printf("time_to_shutdown:\t%lld\n", (long long)r->time_to_shutdown);
76 d_printf("next_audit_record:\t%d\n", r->next_audit_record);
79 static void display_query_info_2(struct lsa_AuditEventsInfo *r)
81 int i;
82 d_printf("Auditing enabled:\t%d\n", r->auditing_mode);
83 d_printf("Auditing categories:\t%d\n", r->count);
84 d_printf("Auditsettings:\n");
85 for (i=0; i<r->count; i++) {
86 const char *val = audit_policy_str(talloc_tos(), r->settings[i]);
87 const char *policy = audit_description_str(i);
88 d_printf("%s:\t%s\n", policy, val);
92 static void display_query_info_3(struct lsa_DomainInfo *r)
94 d_printf("Domain Name: %s\n", r->name.string);
95 d_printf("Domain Sid: %s\n", sid_string_tos(r->sid));
98 static void display_query_info_5(struct lsa_DomainInfo *r)
100 d_printf("Domain Name: %s\n", r->name.string);
101 d_printf("Domain Sid: %s\n", sid_string_tos(r->sid));
104 static void display_query_info_10(struct lsa_AuditFullSetInfo *r)
106 d_printf("Shutdown on full: %d\n", r->shutdown_on_full);
109 static void display_query_info_11(struct lsa_AuditFullQueryInfo *r)
111 d_printf("Shutdown on full: %d\n", r->shutdown_on_full);
112 d_printf("Log is full: %d\n", r->log_is_full);
115 static void display_query_info_12(struct lsa_DnsDomainInfo *r)
117 d_printf("Domain NetBios Name: %s\n", r->name.string);
118 d_printf("Domain DNS Name: %s\n", r->dns_domain.string);
119 d_printf("Domain Forest Name: %s\n", r->dns_forest.string);
120 d_printf("Domain Sid: %s\n", sid_string_tos(r->sid));
121 d_printf("Domain GUID: %s\n", GUID_string(talloc_tos(),
122 &r->domain_guid));
125 static void display_lsa_query_info(union lsa_PolicyInformation *info,
126 enum lsa_PolicyInfo level)
128 switch (level) {
129 case 1:
130 display_query_info_1(&info->audit_log);
131 break;
132 case 2:
133 display_query_info_2(&info->audit_events);
134 break;
135 case 3:
136 display_query_info_3(&info->domain);
137 break;
138 case 5:
139 display_query_info_5(&info->account_domain);
140 break;
141 case 10:
142 display_query_info_10(&info->auditfullset);
143 break;
144 case 11:
145 display_query_info_11(&info->auditfullquery);
146 break;
147 case 12:
148 display_query_info_12(&info->dns);
149 break;
150 default:
151 printf("can't display info level: %d\n", level);
152 break;
156 static NTSTATUS cmd_lsa_query_info_policy(struct rpc_pipe_client *cli,
157 TALLOC_CTX *mem_ctx, int argc,
158 const char **argv)
160 struct policy_handle pol;
161 NTSTATUS status, result;
162 union lsa_PolicyInformation *info = NULL;
163 struct dcerpc_binding_handle *b = cli->binding_handle;
165 uint32 info_class = 3;
167 if (argc > 2) {
168 printf("Usage: %s [info_class]\n", argv[0]);
169 return NT_STATUS_OK;
172 if (argc == 2)
173 info_class = atoi(argv[1]);
175 switch (info_class) {
176 case 12:
177 status = rpccli_lsa_open_policy2(cli, mem_ctx, True,
178 SEC_FLAG_MAXIMUM_ALLOWED,
179 &pol);
181 if (!NT_STATUS_IS_OK(status))
182 goto done;
184 status = dcerpc_lsa_QueryInfoPolicy2(b, mem_ctx,
185 &pol,
186 info_class,
187 &info,
188 &result);
189 break;
190 default:
191 status = rpccli_lsa_open_policy(cli, mem_ctx, True,
192 SEC_FLAG_MAXIMUM_ALLOWED,
193 &pol);
195 if (!NT_STATUS_IS_OK(status))
196 goto done;
198 status = dcerpc_lsa_QueryInfoPolicy(b, mem_ctx,
199 &pol,
200 info_class,
201 &info,
202 &result);
205 if (!NT_STATUS_IS_OK(status)) {
206 goto done;
208 status = result;
209 if (NT_STATUS_IS_OK(result)) {
210 display_lsa_query_info(info, info_class);
213 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
215 done:
216 return status;
219 /* Resolve a list of names to a list of sids */
221 static NTSTATUS cmd_lsa_lookup_names(struct rpc_pipe_client *cli,
222 TALLOC_CTX *mem_ctx, int argc,
223 const char **argv)
225 struct policy_handle pol;
226 NTSTATUS status, result;
227 struct dom_sid *sids;
228 enum lsa_SidType *types;
229 int i;
230 struct dcerpc_binding_handle *b = cli->binding_handle;
232 if (argc == 1) {
233 printf("Usage: %s [name1 [name2 [...]]]\n", argv[0]);
234 return NT_STATUS_OK;
237 status = rpccli_lsa_open_policy(cli, mem_ctx, True,
238 SEC_FLAG_MAXIMUM_ALLOWED,
239 &pol);
241 if (!NT_STATUS_IS_OK(status))
242 goto done;
244 status = rpccli_lsa_lookup_names(cli, mem_ctx, &pol, argc - 1,
245 (const char**)(argv + 1), NULL, 1, &sids, &types);
247 if (!NT_STATUS_IS_OK(status) && NT_STATUS_V(status) !=
248 NT_STATUS_V(STATUS_SOME_UNMAPPED))
249 goto done;
251 status = NT_STATUS_OK;
253 /* Print results */
255 for (i = 0; i < (argc - 1); i++) {
256 fstring sid_str;
257 sid_to_fstring(sid_str, &sids[i]);
258 printf("%s %s (%s: %d)\n", argv[i + 1], sid_str,
259 sid_type_lookup(types[i]), types[i]);
262 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
264 done:
265 return status;
268 /* Resolve a list of names to a list of sids */
270 static NTSTATUS cmd_lsa_lookup_names_level(struct rpc_pipe_client *cli,
271 TALLOC_CTX *mem_ctx, int argc,
272 const char **argv)
274 struct policy_handle pol;
275 NTSTATUS status, result;
276 struct dom_sid *sids;
277 enum lsa_SidType *types;
278 int i, level;
279 struct dcerpc_binding_handle *b = cli->binding_handle;
281 if (argc < 3) {
282 printf("Usage: %s [level] [name1 [name2 [...]]]\n", argv[0]);
283 return NT_STATUS_OK;
286 status = rpccli_lsa_open_policy(cli, mem_ctx, True,
287 SEC_FLAG_MAXIMUM_ALLOWED,
288 &pol);
290 if (!NT_STATUS_IS_OK(status))
291 goto done;
293 level = atoi(argv[1]);
295 status = rpccli_lsa_lookup_names(cli, mem_ctx, &pol, argc - 2,
296 (const char**)(argv + 2), NULL, level, &sids, &types);
298 if (!NT_STATUS_IS_OK(status) && NT_STATUS_V(status) !=
299 NT_STATUS_V(STATUS_SOME_UNMAPPED))
300 goto done;
302 status = NT_STATUS_OK;
304 /* Print results */
306 for (i = 0; i < (argc - 2); i++) {
307 fstring sid_str;
308 sid_to_fstring(sid_str, &sids[i]);
309 printf("%s %s (%s: %d)\n", argv[i + 2], sid_str,
310 sid_type_lookup(types[i]), types[i]);
313 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
315 done:
316 return status;
319 static NTSTATUS cmd_lsa_lookup_names4(struct rpc_pipe_client *cli,
320 TALLOC_CTX *mem_ctx, int argc,
321 const char **argv)
323 NTSTATUS status, result;
325 uint32_t num_names;
326 struct lsa_String *names;
327 struct lsa_RefDomainList *domains;
328 struct lsa_TransSidArray3 sids;
329 uint32_t count = 0;
330 int i;
331 struct dcerpc_binding_handle *b = cli->binding_handle;
333 if (argc == 1) {
334 printf("Usage: %s [name1 [name2 [...]]]\n", argv[0]);
335 return NT_STATUS_OK;
338 ZERO_STRUCT(sids);
340 num_names = argc-1;
341 names = talloc_array(mem_ctx, struct lsa_String, num_names);
342 NT_STATUS_HAVE_NO_MEMORY(names);
344 for (i=0; i < num_names; i++) {
345 init_lsa_String(&names[i], argv[i+1]);
348 status = dcerpc_lsa_LookupNames4(b, mem_ctx,
349 num_names,
350 names,
351 &domains,
352 &sids,
354 &count,
357 &result);
358 if (!NT_STATUS_IS_OK(status)) {
359 return status;
361 if (!NT_STATUS_IS_OK(result)) {
362 return result;
365 for (i = 0; i < sids.count; i++) {
366 fstring sid_str;
367 sid_to_fstring(sid_str, sids.sids[i].sid);
368 printf("%s %s (%s: %d)\n", argv[i+1], sid_str,
369 sid_type_lookup(sids.sids[i].sid_type),
370 sids.sids[i].sid_type);
373 return status;
376 /* Resolve a list of SIDs to a list of names */
378 static NTSTATUS cmd_lsa_lookup_sids(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
379 int argc, const char **argv)
381 struct policy_handle pol;
382 NTSTATUS status, result;
383 struct dom_sid *sids;
384 char **domains;
385 char **names;
386 enum lsa_SidType *types;
387 int i;
388 struct dcerpc_binding_handle *b = cli->binding_handle;
390 if (argc == 1) {
391 printf("Usage: %s [sid1 [sid2 [...]]]\n", argv[0]);
392 return NT_STATUS_OK;
395 status = rpccli_lsa_open_policy(cli, mem_ctx, True,
396 SEC_FLAG_MAXIMUM_ALLOWED,
397 &pol);
399 if (!NT_STATUS_IS_OK(status))
400 goto done;
402 /* Convert arguments to sids */
404 sids = TALLOC_ARRAY(mem_ctx, struct dom_sid, argc - 1);
406 if (!sids) {
407 printf("could not allocate memory for %d sids\n", argc - 1);
408 goto done;
411 for (i = 0; i < argc - 1; i++)
412 if (!string_to_sid(&sids[i], argv[i + 1])) {
413 status = NT_STATUS_INVALID_SID;
414 goto done;
417 /* Lookup the SIDs */
419 status = rpccli_lsa_lookup_sids(cli, mem_ctx, &pol, argc - 1, sids,
420 &domains, &names, &types);
422 if (!NT_STATUS_IS_OK(status) && NT_STATUS_V(status) !=
423 NT_STATUS_V(STATUS_SOME_UNMAPPED))
424 goto done;
426 status = NT_STATUS_OK;
428 /* Print results */
430 for (i = 0; i < (argc - 1); i++) {
431 fstring sid_str;
433 sid_to_fstring(sid_str, &sids[i]);
434 printf("%s %s\\%s (%d)\n", sid_str,
435 domains[i] ? domains[i] : "*unknown*",
436 names[i] ? names[i] : "*unknown*", types[i]);
439 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
441 done:
442 return status;
445 /* Resolve a list of SIDs to a list of names */
447 static NTSTATUS cmd_lsa_lookup_sids3(struct rpc_pipe_client *cli,
448 TALLOC_CTX *mem_ctx,
449 int argc, const char **argv)
451 NTSTATUS status = NT_STATUS_UNSUCCESSFUL, result;
452 int i;
453 struct lsa_SidArray sids;
454 struct lsa_RefDomainList *domains;
455 struct lsa_TransNameArray2 names;
456 uint32_t count = 0;
457 struct dcerpc_binding_handle *b = cli->binding_handle;
459 if (argc == 1) {
460 printf("Usage: %s [sid1 [sid2 [...]]]\n", argv[0]);
461 return NT_STATUS_OK;
464 ZERO_STRUCT(names);
466 /* Convert arguments to sids */
468 sids.num_sids = argc-1;
469 sids.sids = talloc_array(mem_ctx, struct lsa_SidPtr, sids.num_sids);
470 if (!sids.sids) {
471 printf("could not allocate memory for %d sids\n", sids.num_sids);
472 goto done;
475 for (i = 0; i < sids.num_sids; i++) {
476 sids.sids[i].sid = talloc(sids.sids, struct dom_sid);
477 if (sids.sids[i].sid == NULL) {
478 status = NT_STATUS_NO_MEMORY;
479 goto done;
481 if (!string_to_sid(sids.sids[i].sid, argv[i+1])) {
482 status = NT_STATUS_INVALID_SID;
483 goto done;
487 /* Lookup the SIDs */
488 status = dcerpc_lsa_LookupSids3(b, mem_ctx,
489 &sids,
490 &domains,
491 &names,
493 &count,
496 &result);
497 if (!NT_STATUS_IS_OK(status)) {
498 goto done;
500 if (!NT_STATUS_IS_OK(result) && NT_STATUS_V(result) !=
501 NT_STATUS_V(STATUS_SOME_UNMAPPED)) {
502 status = result;
503 goto done;
506 status = NT_STATUS_OK;
508 /* Print results */
510 for (i = 0; i < count; i++) {
511 fstring sid_str;
513 sid_to_fstring(sid_str, sids.sids[i].sid);
514 printf("%s %s (%d)\n", sid_str,
515 names.names[i].name.string,
516 names.names[i].sid_type);
519 done:
520 return status;
524 /* Enumerate list of trusted domains */
526 static NTSTATUS cmd_lsa_enum_trust_dom(struct rpc_pipe_client *cli,
527 TALLOC_CTX *mem_ctx, int argc,
528 const char **argv)
530 struct policy_handle pol;
531 NTSTATUS status, result;
532 struct lsa_DomainList domain_list;
533 struct dcerpc_binding_handle *b = cli->binding_handle;
535 /* defaults, but may be changed using params */
536 uint32 enum_ctx = 0;
537 int i;
538 uint32_t max_size = (uint32_t)-1;
540 if (argc > 2) {
541 printf("Usage: %s [enum context (0)]\n", argv[0]);
542 return NT_STATUS_OK;
545 if (argc == 2 && argv[1]) {
546 enum_ctx = atoi(argv[2]);
549 status = rpccli_lsa_open_policy(cli, mem_ctx, True,
550 LSA_POLICY_VIEW_LOCAL_INFORMATION,
551 &pol);
553 if (!NT_STATUS_IS_OK(status))
554 goto done;
556 status = STATUS_MORE_ENTRIES;
558 while (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) {
560 /* Lookup list of trusted domains */
562 status = dcerpc_lsa_EnumTrustDom(b, mem_ctx,
563 &pol,
564 &enum_ctx,
565 &domain_list,
566 max_size,
567 &result);
568 if (!NT_STATUS_IS_OK(status)) {
569 goto done;
571 if (!NT_STATUS_IS_OK(result) &&
572 !NT_STATUS_EQUAL(result, NT_STATUS_NO_MORE_ENTRIES) &&
573 !NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)) {
574 status = result;
575 goto done;
578 /* Print results: list of names and sids returned in this
579 * response. */
580 for (i = 0; i < domain_list.count; i++) {
581 fstring sid_str;
583 sid_to_fstring(sid_str, domain_list.domains[i].sid);
584 printf("%s %s\n",
585 domain_list.domains[i].name.string ?
586 domain_list.domains[i].name.string : "*unknown*",
587 sid_str);
591 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
592 done:
593 return status;
596 /* Enumerates privileges */
598 static NTSTATUS cmd_lsa_enum_privilege(struct rpc_pipe_client *cli,
599 TALLOC_CTX *mem_ctx, int argc,
600 const char **argv)
602 struct policy_handle pol;
603 NTSTATUS status, result;
604 struct lsa_PrivArray priv_array;
605 struct dcerpc_binding_handle *b = cli->binding_handle;
607 uint32 enum_context=0;
608 uint32 pref_max_length=0x1000;
609 int i;
611 if (argc > 3) {
612 printf("Usage: %s [enum context] [max length]\n", argv[0]);
613 return NT_STATUS_OK;
616 if (argc>=2)
617 enum_context=atoi(argv[1]);
619 if (argc==3)
620 pref_max_length=atoi(argv[2]);
622 status = rpccli_lsa_open_policy(cli, mem_ctx, True,
623 SEC_FLAG_MAXIMUM_ALLOWED,
624 &pol);
626 if (!NT_STATUS_IS_OK(status))
627 goto done;
629 status = dcerpc_lsa_EnumPrivs(b, mem_ctx,
630 &pol,
631 &enum_context,
632 &priv_array,
633 pref_max_length,
634 &result);
635 if (!NT_STATUS_IS_OK(status))
636 goto done;
637 if (!NT_STATUS_IS_OK(result)) {
638 status = result;
639 goto done;
642 /* Print results */
643 printf("found %d privileges\n\n", priv_array.count);
645 for (i = 0; i < priv_array.count; i++) {
646 printf("%s \t\t%d:%d (0x%x:0x%x)\n",
647 priv_array.privs[i].name.string ? priv_array.privs[i].name.string : "*unknown*",
648 priv_array.privs[i].luid.high,
649 priv_array.privs[i].luid.low,
650 priv_array.privs[i].luid.high,
651 priv_array.privs[i].luid.low);
654 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
655 done:
656 return status;
659 /* Get privilege name */
661 static NTSTATUS cmd_lsa_get_dispname(struct rpc_pipe_client *cli,
662 TALLOC_CTX *mem_ctx, int argc,
663 const char **argv)
665 struct policy_handle pol;
666 NTSTATUS status, result;
667 struct dcerpc_binding_handle *b = cli->binding_handle;
669 uint16 lang_id=0;
670 uint16 lang_id_sys=0;
671 uint16 lang_id_desc;
672 struct lsa_String lsa_name;
673 struct lsa_StringLarge *description = NULL;
675 if (argc != 2) {
676 printf("Usage: %s privilege name\n", argv[0]);
677 return NT_STATUS_OK;
680 status = rpccli_lsa_open_policy(cli, mem_ctx, True,
681 SEC_FLAG_MAXIMUM_ALLOWED,
682 &pol);
684 if (!NT_STATUS_IS_OK(status))
685 goto done;
687 init_lsa_String(&lsa_name, argv[1]);
689 status = dcerpc_lsa_LookupPrivDisplayName(b, mem_ctx,
690 &pol,
691 &lsa_name,
692 lang_id,
693 lang_id_sys,
694 &description,
695 &lang_id_desc,
696 &result);
697 if (!NT_STATUS_IS_OK(status))
698 goto done;
699 if (!NT_STATUS_IS_OK(result)) {
700 status = result;
701 goto done;
704 /* Print results */
705 printf("%s -> %s (language: 0x%x)\n", argv[1], description->string, lang_id_desc);
707 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
708 done:
709 return status;
712 /* Enumerate the LSA SIDS */
714 static NTSTATUS cmd_lsa_enum_sids(struct rpc_pipe_client *cli,
715 TALLOC_CTX *mem_ctx, int argc,
716 const char **argv)
718 struct policy_handle pol;
719 NTSTATUS status, result;
720 struct dcerpc_binding_handle *b = cli->binding_handle;
722 uint32 enum_context=0;
723 uint32 pref_max_length=0x1000;
724 struct lsa_SidArray sid_array;
725 int i;
727 if (argc > 3) {
728 printf("Usage: %s [enum context] [max length]\n", argv[0]);
729 return NT_STATUS_OK;
732 if (argc>=2)
733 enum_context=atoi(argv[1]);
735 if (argc==3)
736 pref_max_length=atoi(argv[2]);
738 status = rpccli_lsa_open_policy(cli, mem_ctx, True,
739 SEC_FLAG_MAXIMUM_ALLOWED,
740 &pol);
742 if (!NT_STATUS_IS_OK(status))
743 goto done;
745 status = dcerpc_lsa_EnumAccounts(b, mem_ctx,
746 &pol,
747 &enum_context,
748 &sid_array,
749 pref_max_length,
750 &result);
751 if (!NT_STATUS_IS_OK(status))
752 goto done;
753 if (!NT_STATUS_IS_OK(result)) {
754 status = result;
755 goto done;
758 /* Print results */
759 printf("found %d SIDs\n\n", sid_array.num_sids);
761 for (i = 0; i < sid_array.num_sids; i++) {
762 fstring sid_str;
764 sid_to_fstring(sid_str, sid_array.sids[i].sid);
765 printf("%s\n", sid_str);
768 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
769 done:
770 return status;
773 /* Create a new account */
775 static NTSTATUS cmd_lsa_create_account(struct rpc_pipe_client *cli,
776 TALLOC_CTX *mem_ctx, int argc,
777 const char **argv)
779 struct policy_handle dom_pol;
780 struct policy_handle user_pol;
781 NTSTATUS status, result;
782 uint32 des_access = 0x000f000f;
783 struct dcerpc_binding_handle *b = cli->binding_handle;
785 struct dom_sid sid;
787 if (argc != 2 ) {
788 printf("Usage: %s SID\n", argv[0]);
789 return NT_STATUS_OK;
792 status = name_to_sid(cli, mem_ctx, &sid, argv[1]);
793 if (!NT_STATUS_IS_OK(status))
794 goto done;
796 status = rpccli_lsa_open_policy2(cli, mem_ctx, True,
797 SEC_FLAG_MAXIMUM_ALLOWED,
798 &dom_pol);
800 if (!NT_STATUS_IS_OK(status))
801 goto done;
803 status = dcerpc_lsa_CreateAccount(b, mem_ctx,
804 &dom_pol,
805 &sid,
806 des_access,
807 &user_pol,
808 &result);
809 if (!NT_STATUS_IS_OK(status))
810 goto done;
811 if (!NT_STATUS_IS_OK(result)) {
812 status = result;
813 goto done;
816 printf("Account for SID %s successfully created\n\n", argv[1]);
817 status = NT_STATUS_OK;
819 dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result);
820 done:
821 return status;
825 /* Enumerate the privileges of an SID */
827 static NTSTATUS cmd_lsa_enum_privsaccounts(struct rpc_pipe_client *cli,
828 TALLOC_CTX *mem_ctx, int argc,
829 const char **argv)
831 struct policy_handle dom_pol;
832 struct policy_handle user_pol;
833 NTSTATUS status, result;
834 uint32 access_desired = 0x000f000f;
835 struct dom_sid sid;
836 struct lsa_PrivilegeSet *privs = NULL;
837 int i;
838 struct dcerpc_binding_handle *b = cli->binding_handle;
840 if (argc != 2 ) {
841 printf("Usage: %s SID\n", argv[0]);
842 return NT_STATUS_OK;
845 status = name_to_sid(cli, mem_ctx, &sid, argv[1]);
846 if (!NT_STATUS_IS_OK(status))
847 goto done;
849 status = rpccli_lsa_open_policy2(cli, mem_ctx, True,
850 SEC_FLAG_MAXIMUM_ALLOWED,
851 &dom_pol);
853 if (!NT_STATUS_IS_OK(status))
854 goto done;
856 status = dcerpc_lsa_OpenAccount(b, mem_ctx,
857 &dom_pol,
858 &sid,
859 access_desired,
860 &user_pol,
861 &result);
862 if (!NT_STATUS_IS_OK(status))
863 goto done;
864 if (!NT_STATUS_IS_OK(result)) {
865 status = result;
866 goto done;
869 status = dcerpc_lsa_EnumPrivsAccount(b, mem_ctx,
870 &user_pol,
871 &privs,
872 &result);
873 if (!NT_STATUS_IS_OK(status))
874 goto done;
875 if (!NT_STATUS_IS_OK(result)) {
876 status = result;
877 goto done;
880 /* Print results */
881 printf("found %d privileges for SID %s\n\n", privs->count, argv[1]);
882 printf("high\tlow\tattribute\n");
884 for (i = 0; i < privs->count; i++) {
885 printf("%u\t%u\t%u\n",
886 privs->set[i].luid.high,
887 privs->set[i].luid.low,
888 privs->set[i].attribute);
891 dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result);
892 done:
893 return status;
897 /* Enumerate the privileges of an SID via LsaEnumerateAccountRights */
899 static NTSTATUS cmd_lsa_enum_acct_rights(struct rpc_pipe_client *cli,
900 TALLOC_CTX *mem_ctx, int argc,
901 const char **argv)
903 struct policy_handle dom_pol;
904 NTSTATUS status, result;
905 struct dom_sid sid;
906 struct lsa_RightSet rights;
907 struct dcerpc_binding_handle *b = cli->binding_handle;
909 int i;
911 if (argc != 2 ) {
912 printf("Usage: %s SID\n", argv[0]);
913 return NT_STATUS_OK;
916 status = name_to_sid(cli, mem_ctx, &sid, argv[1]);
917 if (!NT_STATUS_IS_OK(status))
918 goto done;
920 status = rpccli_lsa_open_policy2(cli, mem_ctx, True,
921 SEC_FLAG_MAXIMUM_ALLOWED,
922 &dom_pol);
924 if (!NT_STATUS_IS_OK(status))
925 goto done;
927 status = dcerpc_lsa_EnumAccountRights(b, mem_ctx,
928 &dom_pol,
929 &sid,
930 &rights,
931 &result);
932 if (!NT_STATUS_IS_OK(status))
933 goto done;
934 if (!NT_STATUS_IS_OK(result)) {
935 status = result;
936 goto done;
939 printf("found %d privileges for SID %s\n", rights.count,
940 sid_string_tos(&sid));
942 for (i = 0; i < rights.count; i++) {
943 printf("\t%s\n", rights.names[i].string);
946 dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result);
947 done:
948 return status;
952 /* add some privileges to a SID via LsaAddAccountRights */
954 static NTSTATUS cmd_lsa_add_acct_rights(struct rpc_pipe_client *cli,
955 TALLOC_CTX *mem_ctx, int argc,
956 const char **argv)
958 struct policy_handle dom_pol;
959 NTSTATUS status, result;
960 struct lsa_RightSet rights;
961 struct dom_sid sid;
962 int i;
963 struct dcerpc_binding_handle *b = cli->binding_handle;
965 if (argc < 3 ) {
966 printf("Usage: %s SID [rights...]\n", argv[0]);
967 return NT_STATUS_OK;
970 status = name_to_sid(cli, mem_ctx, &sid, argv[1]);
971 if (!NT_STATUS_IS_OK(status))
972 goto done;
974 status = rpccli_lsa_open_policy2(cli, mem_ctx, True,
975 SEC_FLAG_MAXIMUM_ALLOWED,
976 &dom_pol);
978 if (!NT_STATUS_IS_OK(status))
979 goto done;
981 rights.count = argc-2;
982 rights.names = TALLOC_ARRAY(mem_ctx, struct lsa_StringLarge,
983 rights.count);
984 if (!rights.names) {
985 return NT_STATUS_NO_MEMORY;
988 for (i=0; i<argc-2; i++) {
989 init_lsa_StringLarge(&rights.names[i], argv[i+2]);
992 status = dcerpc_lsa_AddAccountRights(b, mem_ctx,
993 &dom_pol,
994 &sid,
995 &rights,
996 &result);
997 if (!NT_STATUS_IS_OK(status))
998 goto done;
999 if (!NT_STATUS_IS_OK(result)) {
1000 status = result;
1001 goto done;
1004 dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result);
1005 done:
1006 return status;
1010 /* remove some privileges to a SID via LsaRemoveAccountRights */
1012 static NTSTATUS cmd_lsa_remove_acct_rights(struct rpc_pipe_client *cli,
1013 TALLOC_CTX *mem_ctx, int argc,
1014 const char **argv)
1016 struct policy_handle dom_pol;
1017 NTSTATUS status, result;
1018 struct lsa_RightSet rights;
1019 struct dom_sid sid;
1020 int i;
1021 struct dcerpc_binding_handle *b = cli->binding_handle;
1023 if (argc < 3 ) {
1024 printf("Usage: %s SID [rights...]\n", argv[0]);
1025 return NT_STATUS_OK;
1028 status = name_to_sid(cli, mem_ctx, &sid, argv[1]);
1029 if (!NT_STATUS_IS_OK(status))
1030 goto done;
1032 status = rpccli_lsa_open_policy2(cli, mem_ctx, True,
1033 SEC_FLAG_MAXIMUM_ALLOWED,
1034 &dom_pol);
1036 if (!NT_STATUS_IS_OK(status))
1037 goto done;
1039 rights.count = argc-2;
1040 rights.names = TALLOC_ARRAY(mem_ctx, struct lsa_StringLarge,
1041 rights.count);
1042 if (!rights.names) {
1043 return NT_STATUS_NO_MEMORY;
1046 for (i=0; i<argc-2; i++) {
1047 init_lsa_StringLarge(&rights.names[i], argv[i+2]);
1050 status = dcerpc_lsa_RemoveAccountRights(b, mem_ctx,
1051 &dom_pol,
1052 &sid,
1053 false,
1054 &rights,
1055 &result);
1056 if (!NT_STATUS_IS_OK(status))
1057 goto done;
1058 if (!NT_STATUS_IS_OK(result)) {
1059 status = result;
1060 goto done;
1063 dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result);
1065 done:
1066 return status;
1070 /* Get a privilege value given its name */
1072 static NTSTATUS cmd_lsa_lookup_priv_value(struct rpc_pipe_client *cli,
1073 TALLOC_CTX *mem_ctx, int argc,
1074 const char **argv)
1076 struct policy_handle pol;
1077 NTSTATUS status, result;
1078 struct lsa_LUID luid;
1079 struct lsa_String name;
1080 struct dcerpc_binding_handle *b = cli->binding_handle;
1082 if (argc != 2 ) {
1083 printf("Usage: %s name\n", argv[0]);
1084 return NT_STATUS_OK;
1087 status = rpccli_lsa_open_policy2(cli, mem_ctx, True,
1088 SEC_FLAG_MAXIMUM_ALLOWED,
1089 &pol);
1091 if (!NT_STATUS_IS_OK(status))
1092 goto done;
1094 init_lsa_String(&name, argv[1]);
1096 status = dcerpc_lsa_LookupPrivValue(b, mem_ctx,
1097 &pol,
1098 &name,
1099 &luid,
1100 &result);
1101 if (!NT_STATUS_IS_OK(status))
1102 goto done;
1103 if (!NT_STATUS_IS_OK(result)) {
1104 status = result;
1105 goto done;
1108 /* Print results */
1110 printf("%u:%u (0x%x:0x%x)\n", luid.high, luid.low, luid.high, luid.low);
1112 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
1113 done:
1114 return status;
1117 /* Query LSA security object */
1119 static NTSTATUS cmd_lsa_query_secobj(struct rpc_pipe_client *cli,
1120 TALLOC_CTX *mem_ctx, int argc,
1121 const char **argv)
1123 struct policy_handle pol;
1124 NTSTATUS status, result;
1125 struct sec_desc_buf *sdb;
1126 uint32 sec_info = SECINFO_DACL;
1127 struct dcerpc_binding_handle *b = cli->binding_handle;
1129 if (argc < 1 || argc > 2) {
1130 printf("Usage: %s [sec_info]\n", argv[0]);
1131 return NT_STATUS_OK;
1134 status = rpccli_lsa_open_policy2(cli, mem_ctx, True,
1135 SEC_FLAG_MAXIMUM_ALLOWED,
1136 &pol);
1138 if (argc == 2)
1139 sscanf(argv[1], "%x", &sec_info);
1141 if (!NT_STATUS_IS_OK(status))
1142 goto done;
1144 status = dcerpc_lsa_QuerySecurity(b, mem_ctx,
1145 &pol,
1146 sec_info,
1147 &sdb,
1148 &result);
1149 if (!NT_STATUS_IS_OK(status))
1150 goto done;
1151 if (!NT_STATUS_IS_OK(result)) {
1152 status = result;
1153 goto done;
1156 /* Print results */
1158 display_sec_desc(sdb->sd);
1160 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
1161 done:
1162 return status;
1165 static void display_trust_dom_info_4(struct lsa_TrustDomainInfoPassword *p,
1166 uint8_t session_key[16])
1168 char *pwd, *pwd_old;
1170 DATA_BLOB data = data_blob_const(p->password->data, p->password->length);
1171 DATA_BLOB data_old = data_blob_const(p->old_password->data, p->old_password->length);
1172 DATA_BLOB session_key_blob = data_blob_const(session_key, sizeof(session_key));
1174 pwd = sess_decrypt_string(talloc_tos(), &data, &session_key_blob);
1175 pwd_old = sess_decrypt_string(talloc_tos(), &data_old, &session_key_blob);
1177 d_printf("Password:\t%s\n", pwd);
1178 d_printf("Old Password:\t%s\n", pwd_old);
1180 talloc_free(pwd);
1181 talloc_free(pwd_old);
1184 static void display_trust_dom_info(TALLOC_CTX *mem_ctx,
1185 union lsa_TrustedDomainInfo *info,
1186 enum lsa_TrustDomInfoEnum info_class,
1187 uint8_t nt_hash[16])
1189 switch (info_class) {
1190 case LSA_TRUSTED_DOMAIN_INFO_PASSWORD:
1191 display_trust_dom_info_4(&info->password, nt_hash);
1192 break;
1193 default: {
1194 const char *str = NULL;
1195 str = NDR_PRINT_UNION_STRING(mem_ctx,
1196 lsa_TrustedDomainInfo,
1197 info_class, info);
1198 if (str) {
1199 d_printf("%s\n", str);
1201 break;
1206 static NTSTATUS cmd_lsa_query_trustdominfobysid(struct rpc_pipe_client *cli,
1207 TALLOC_CTX *mem_ctx, int argc,
1208 const char **argv)
1210 struct policy_handle pol;
1211 NTSTATUS status, result;
1212 struct dom_sid dom_sid;
1213 uint32 access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
1214 union lsa_TrustedDomainInfo *info = NULL;
1215 enum lsa_TrustDomInfoEnum info_class = 1;
1216 uint8_t nt_hash[16];
1217 struct dcerpc_binding_handle *b = cli->binding_handle;
1219 if (argc > 3 || argc < 2) {
1220 printf("Usage: %s [sid] [info_class]\n", argv[0]);
1221 return NT_STATUS_OK;
1224 if (!string_to_sid(&dom_sid, argv[1]))
1225 return NT_STATUS_NO_MEMORY;
1227 if (argc == 3)
1228 info_class = atoi(argv[2]);
1230 status = rpccli_lsa_open_policy2(cli, mem_ctx, True, access_mask, &pol);
1232 if (!NT_STATUS_IS_OK(status))
1233 goto done;
1235 status = dcerpc_lsa_QueryTrustedDomainInfoBySid(b, mem_ctx,
1236 &pol,
1237 &dom_sid,
1238 info_class,
1239 &info,
1240 &result);
1241 if (!NT_STATUS_IS_OK(status))
1242 goto done;
1243 if (!NT_STATUS_IS_OK(result)) {
1244 status = result;
1245 goto done;
1248 if (!rpccli_get_pwd_hash(cli, nt_hash)) {
1249 d_fprintf(stderr, "Could not get pwd hash\n");
1250 goto done;
1253 display_trust_dom_info(mem_ctx, info, info_class, nt_hash);
1255 done:
1256 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
1258 return status;
1261 static NTSTATUS cmd_lsa_query_trustdominfobyname(struct rpc_pipe_client *cli,
1262 TALLOC_CTX *mem_ctx, int argc,
1263 const char **argv)
1265 struct policy_handle pol;
1266 NTSTATUS status, result;
1267 uint32 access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
1268 union lsa_TrustedDomainInfo *info = NULL;
1269 enum lsa_TrustDomInfoEnum info_class = 1;
1270 struct lsa_String trusted_domain;
1271 uint8_t nt_hash[16];
1272 struct dcerpc_binding_handle *b = cli->binding_handle;
1274 if (argc > 3 || argc < 2) {
1275 printf("Usage: %s [name] [info_class]\n", argv[0]);
1276 return NT_STATUS_OK;
1279 if (argc == 3)
1280 info_class = atoi(argv[2]);
1282 status = rpccli_lsa_open_policy2(cli, mem_ctx, True, access_mask, &pol);
1284 if (!NT_STATUS_IS_OK(status))
1285 goto done;
1287 init_lsa_String(&trusted_domain, argv[1]);
1289 status = dcerpc_lsa_QueryTrustedDomainInfoByName(b, mem_ctx,
1290 &pol,
1291 &trusted_domain,
1292 info_class,
1293 &info,
1294 &result);
1295 if (!NT_STATUS_IS_OK(status))
1296 goto done;
1297 if (!NT_STATUS_IS_OK(result)) {
1298 status = result;
1299 goto done;
1302 if (!rpccli_get_pwd_hash(cli, nt_hash)) {
1303 d_fprintf(stderr, "Could not get pwd hash\n");
1304 goto done;
1307 display_trust_dom_info(mem_ctx, info, info_class, nt_hash);
1309 done:
1310 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
1312 return status;
1315 static NTSTATUS cmd_lsa_query_trustdominfo(struct rpc_pipe_client *cli,
1316 TALLOC_CTX *mem_ctx, int argc,
1317 const char **argv)
1319 struct policy_handle pol, trustdom_pol;
1320 NTSTATUS status, result;
1321 uint32 access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
1322 union lsa_TrustedDomainInfo *info = NULL;
1323 struct dom_sid dom_sid;
1324 enum lsa_TrustDomInfoEnum info_class = 1;
1325 uint8_t nt_hash[16];
1326 struct dcerpc_binding_handle *b = cli->binding_handle;
1328 if (argc > 3 || argc < 2) {
1329 printf("Usage: %s [sid] [info_class]\n", argv[0]);
1330 return NT_STATUS_OK;
1333 if (!string_to_sid(&dom_sid, argv[1]))
1334 return NT_STATUS_NO_MEMORY;
1337 if (argc == 3)
1338 info_class = atoi(argv[2]);
1340 status = rpccli_lsa_open_policy2(cli, mem_ctx, True, access_mask, &pol);
1342 if (!NT_STATUS_IS_OK(status))
1343 goto done;
1345 status = dcerpc_lsa_OpenTrustedDomain(b, mem_ctx,
1346 &pol,
1347 &dom_sid,
1348 access_mask,
1349 &trustdom_pol,
1350 &result);
1351 if (!NT_STATUS_IS_OK(status))
1352 goto done;
1353 if (!NT_STATUS_IS_OK(result)) {
1354 status = result;
1355 goto done;
1358 status = dcerpc_lsa_QueryTrustedDomainInfo(b, mem_ctx,
1359 &trustdom_pol,
1360 info_class,
1361 &info,
1362 &result);
1363 if (!NT_STATUS_IS_OK(status))
1364 goto done;
1365 if (!NT_STATUS_IS_OK(result)) {
1366 status = result;
1367 goto done;
1370 if (!rpccli_get_pwd_hash(cli, nt_hash)) {
1371 d_fprintf(stderr, "Could not get pwd hash\n");
1372 goto done;
1375 display_trust_dom_info(mem_ctx, info, info_class, nt_hash);
1377 done:
1378 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
1380 return status;
1383 static NTSTATUS cmd_lsa_get_username(struct rpc_pipe_client *cli,
1384 TALLOC_CTX *mem_ctx, int argc,
1385 const char **argv)
1387 struct policy_handle pol;
1388 NTSTATUS status, result;
1389 const char *servername = cli->desthost;
1390 struct lsa_String *account_name = NULL;
1391 struct lsa_String *authority_name = NULL;
1392 struct dcerpc_binding_handle *b = cli->binding_handle;
1394 if (argc > 2) {
1395 printf("Usage: %s servername\n", argv[0]);
1396 return NT_STATUS_OK;
1399 status = rpccli_lsa_open_policy(cli, mem_ctx, true,
1400 SEC_FLAG_MAXIMUM_ALLOWED,
1401 &pol);
1403 if (!NT_STATUS_IS_OK(status)) {
1404 goto done;
1407 status = dcerpc_lsa_GetUserName(b, mem_ctx,
1408 servername,
1409 &account_name,
1410 &authority_name,
1411 &result);
1412 if (!NT_STATUS_IS_OK(status)) {
1413 goto done;
1415 if (!NT_STATUS_IS_OK(result)) {
1416 status = result;
1417 goto done;
1420 /* Print results */
1422 printf("Account Name: %s, Authority Name: %s\n",
1423 account_name->string, authority_name ? authority_name->string :
1424 "");
1426 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
1427 done:
1428 return status;
1431 static NTSTATUS cmd_lsa_add_priv(struct rpc_pipe_client *cli,
1432 TALLOC_CTX *mem_ctx, int argc,
1433 const char **argv)
1435 struct policy_handle dom_pol, user_pol;
1436 NTSTATUS status, result;
1437 struct lsa_PrivilegeSet privs;
1438 struct lsa_LUIDAttribute *set = NULL;
1439 struct dom_sid sid;
1440 int i;
1441 struct dcerpc_binding_handle *b = cli->binding_handle;
1443 ZERO_STRUCT(privs);
1445 if (argc < 3 ) {
1446 printf("Usage: %s SID [rights...]\n", argv[0]);
1447 return NT_STATUS_OK;
1450 status = name_to_sid(cli, mem_ctx, &sid, argv[1]);
1451 if (!NT_STATUS_IS_OK(status)) {
1452 goto done;
1455 status = rpccli_lsa_open_policy2(cli, mem_ctx, True,
1456 SEC_FLAG_MAXIMUM_ALLOWED,
1457 &dom_pol);
1459 if (!NT_STATUS_IS_OK(status)) {
1460 goto done;
1463 status = dcerpc_lsa_OpenAccount(b, mem_ctx,
1464 &dom_pol,
1465 &sid,
1466 SEC_FLAG_MAXIMUM_ALLOWED,
1467 &user_pol,
1468 &result);
1469 if (!NT_STATUS_IS_OK(status)) {
1470 goto done;
1472 if (!NT_STATUS_IS_OK(result)) {
1473 status = result;
1474 goto done;
1477 for (i=2; i<argc; i++) {
1479 struct lsa_String priv_name;
1480 struct lsa_LUID luid;
1482 init_lsa_String(&priv_name, argv[i]);
1484 status = dcerpc_lsa_LookupPrivValue(b, mem_ctx,
1485 &dom_pol,
1486 &priv_name,
1487 &luid,
1488 &result);
1489 if (!NT_STATUS_IS_OK(status)) {
1490 continue;
1492 if (!NT_STATUS_IS_OK(result)) {
1493 status = result;
1494 continue;
1497 privs.count++;
1498 set = TALLOC_REALLOC_ARRAY(mem_ctx, set,
1499 struct lsa_LUIDAttribute,
1500 privs.count);
1501 if (!set) {
1502 return NT_STATUS_NO_MEMORY;
1505 set[privs.count-1].luid = luid;
1506 set[privs.count-1].attribute = 0;
1509 privs.set = set;
1511 status = dcerpc_lsa_AddPrivilegesToAccount(b, mem_ctx,
1512 &user_pol,
1513 &privs,
1514 &result);
1515 if (!NT_STATUS_IS_OK(status)) {
1516 goto done;
1518 if (!NT_STATUS_IS_OK(result)) {
1519 status = result;
1520 goto done;
1523 dcerpc_lsa_Close(b, mem_ctx, &user_pol, &result);
1524 dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result);
1525 done:
1526 return status;
1529 static NTSTATUS cmd_lsa_del_priv(struct rpc_pipe_client *cli,
1530 TALLOC_CTX *mem_ctx, int argc,
1531 const char **argv)
1533 struct policy_handle dom_pol, user_pol;
1534 NTSTATUS status, result;
1535 struct lsa_PrivilegeSet privs;
1536 struct lsa_LUIDAttribute *set = NULL;
1537 struct dom_sid sid;
1538 int i;
1539 struct dcerpc_binding_handle *b = cli->binding_handle;
1541 ZERO_STRUCT(privs);
1543 if (argc < 3 ) {
1544 printf("Usage: %s SID [rights...]\n", argv[0]);
1545 return NT_STATUS_OK;
1548 status = name_to_sid(cli, mem_ctx, &sid, argv[1]);
1549 if (!NT_STATUS_IS_OK(status)) {
1550 goto done;
1553 status = rpccli_lsa_open_policy2(cli, mem_ctx, True,
1554 SEC_FLAG_MAXIMUM_ALLOWED,
1555 &dom_pol);
1557 if (!NT_STATUS_IS_OK(status)) {
1558 goto done;
1561 status = dcerpc_lsa_OpenAccount(b, mem_ctx,
1562 &dom_pol,
1563 &sid,
1564 SEC_FLAG_MAXIMUM_ALLOWED,
1565 &user_pol,
1566 &result);
1567 if (!NT_STATUS_IS_OK(status)) {
1568 goto done;
1570 if (!NT_STATUS_IS_OK(result)) {
1571 status = result;
1572 goto done;
1575 for (i=2; i<argc; i++) {
1577 struct lsa_String priv_name;
1578 struct lsa_LUID luid;
1580 init_lsa_String(&priv_name, argv[i]);
1582 status = dcerpc_lsa_LookupPrivValue(b, mem_ctx,
1583 &dom_pol,
1584 &priv_name,
1585 &luid,
1586 &result);
1587 if (!NT_STATUS_IS_OK(status)) {
1588 continue;
1590 if (!NT_STATUS_IS_OK(result)) {
1591 status = result;
1592 continue;
1595 privs.count++;
1596 set = TALLOC_REALLOC_ARRAY(mem_ctx, set,
1597 struct lsa_LUIDAttribute,
1598 privs.count);
1599 if (!set) {
1600 return NT_STATUS_NO_MEMORY;
1603 set[privs.count-1].luid = luid;
1604 set[privs.count-1].attribute = 0;
1607 privs.set = set;
1610 status = dcerpc_lsa_RemovePrivilegesFromAccount(b, mem_ctx,
1611 &user_pol,
1612 false,
1613 &privs,
1614 &result);
1615 if (!NT_STATUS_IS_OK(status)) {
1616 goto done;
1618 if (!NT_STATUS_IS_OK(result)) {
1619 status = result;
1620 goto done;
1623 dcerpc_lsa_Close(b, mem_ctx, &user_pol, &result);
1624 dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result);
1625 done:
1626 return status;
1629 static NTSTATUS cmd_lsa_create_secret(struct rpc_pipe_client *cli,
1630 TALLOC_CTX *mem_ctx, int argc,
1631 const char **argv)
1633 NTSTATUS status, result;
1634 struct policy_handle handle, sec_handle;
1635 struct lsa_String name;
1636 struct dcerpc_binding_handle *b = cli->binding_handle;
1638 if (argc < 2) {
1639 printf("Usage: %s name\n", argv[0]);
1640 return NT_STATUS_OK;
1643 status = rpccli_lsa_open_policy2(cli, mem_ctx,
1644 true,
1645 SEC_FLAG_MAXIMUM_ALLOWED,
1646 &handle);
1647 if (!NT_STATUS_IS_OK(status)) {
1648 return status;
1651 init_lsa_String(&name, argv[1]);
1653 status = dcerpc_lsa_CreateSecret(b, mem_ctx,
1654 &handle,
1655 name,
1656 SEC_FLAG_MAXIMUM_ALLOWED,
1657 &sec_handle,
1658 &result);
1659 if (!NT_STATUS_IS_OK(status)) {
1660 goto done;
1662 if (!NT_STATUS_IS_OK(result)) {
1663 status = result;
1664 goto done;
1667 done:
1668 if (is_valid_policy_hnd(&sec_handle)) {
1669 dcerpc_lsa_Close(b, mem_ctx, &sec_handle, &result);
1671 if (is_valid_policy_hnd(&handle)) {
1672 dcerpc_lsa_Close(b, mem_ctx, &handle, &result);
1675 return status;
1678 static NTSTATUS cmd_lsa_delete_secret(struct rpc_pipe_client *cli,
1679 TALLOC_CTX *mem_ctx, int argc,
1680 const char **argv)
1682 NTSTATUS status, result;
1683 struct policy_handle handle, sec_handle;
1684 struct lsa_String name;
1685 struct dcerpc_binding_handle *b = cli->binding_handle;
1687 if (argc < 2) {
1688 printf("Usage: %s name\n", argv[0]);
1689 return NT_STATUS_OK;
1692 status = rpccli_lsa_open_policy2(cli, mem_ctx,
1693 true,
1694 SEC_FLAG_MAXIMUM_ALLOWED,
1695 &handle);
1696 if (!NT_STATUS_IS_OK(status)) {
1697 return status;
1700 init_lsa_String(&name, argv[1]);
1702 status = dcerpc_lsa_OpenSecret(b, mem_ctx,
1703 &handle,
1704 name,
1705 SEC_FLAG_MAXIMUM_ALLOWED,
1706 &sec_handle,
1707 &result);
1708 if (!NT_STATUS_IS_OK(status)) {
1709 goto done;
1711 if (!NT_STATUS_IS_OK(result)) {
1712 status = result;
1713 goto done;
1716 status = dcerpc_lsa_DeleteObject(b, mem_ctx,
1717 &sec_handle,
1718 &result);
1719 if (!NT_STATUS_IS_OK(status)) {
1720 goto done;
1722 if (!NT_STATUS_IS_OK(result)) {
1723 status = result;
1724 goto done;
1727 done:
1728 if (is_valid_policy_hnd(&sec_handle)) {
1729 dcerpc_lsa_Close(b, mem_ctx, &sec_handle, &result);
1731 if (is_valid_policy_hnd(&handle)) {
1732 dcerpc_lsa_Close(b, mem_ctx, &handle, &result);
1735 return status;
1738 static NTSTATUS cmd_lsa_query_secret(struct rpc_pipe_client *cli,
1739 TALLOC_CTX *mem_ctx, int argc,
1740 const char **argv)
1742 NTSTATUS status, result;
1743 struct policy_handle handle, sec_handle;
1744 struct lsa_String name;
1745 struct lsa_DATA_BUF_PTR new_val;
1746 NTTIME new_mtime = 0;
1747 struct lsa_DATA_BUF_PTR old_val;
1748 NTTIME old_mtime = 0;
1749 DATA_BLOB session_key;
1750 DATA_BLOB new_blob = data_blob_null;
1751 DATA_BLOB old_blob = data_blob_null;
1752 char *new_secret, *old_secret;
1753 struct dcerpc_binding_handle *b = cli->binding_handle;
1755 if (argc < 2) {
1756 printf("Usage: %s name\n", argv[0]);
1757 return NT_STATUS_OK;
1760 status = rpccli_lsa_open_policy2(cli, mem_ctx,
1761 true,
1762 SEC_FLAG_MAXIMUM_ALLOWED,
1763 &handle);
1764 if (!NT_STATUS_IS_OK(status)) {
1765 return status;
1768 init_lsa_String(&name, argv[1]);
1770 status = dcerpc_lsa_OpenSecret(b, mem_ctx,
1771 &handle,
1772 name,
1773 SEC_FLAG_MAXIMUM_ALLOWED,
1774 &sec_handle,
1775 &result);
1776 if (!NT_STATUS_IS_OK(status)) {
1777 goto done;
1779 if (!NT_STATUS_IS_OK(result)) {
1780 status = result;
1781 goto done;
1784 ZERO_STRUCT(new_val);
1785 ZERO_STRUCT(old_val);
1787 status = dcerpc_lsa_QuerySecret(b, mem_ctx,
1788 &sec_handle,
1789 &new_val,
1790 &new_mtime,
1791 &old_val,
1792 &old_mtime,
1793 &result);
1794 if (!NT_STATUS_IS_OK(status)) {
1795 goto done;
1797 if (!NT_STATUS_IS_OK(result)) {
1798 status = result;
1799 goto done;
1802 status = cli_get_session_key(mem_ctx, cli, &session_key);
1803 if (!NT_STATUS_IS_OK(status)) {
1804 goto done;
1807 if (new_val.buf) {
1808 new_blob = data_blob_const(new_val.buf->data, new_val.buf->length);
1810 if (old_val.buf) {
1811 old_blob = data_blob_const(old_val.buf->data, old_val.buf->length);
1814 new_secret = sess_decrypt_string(mem_ctx, &new_blob, &session_key);
1815 old_secret = sess_decrypt_string(mem_ctx, &old_blob, &session_key);
1816 if (new_secret) {
1817 d_printf("new secret: %s\n", new_secret);
1819 if (old_secret) {
1820 d_printf("old secret: %s\n", old_secret);
1823 done:
1824 if (is_valid_policy_hnd(&sec_handle)) {
1825 dcerpc_lsa_Close(b, mem_ctx, &sec_handle, &result);
1827 if (is_valid_policy_hnd(&handle)) {
1828 dcerpc_lsa_Close(b, mem_ctx, &handle, &result);
1831 return status;
1834 static NTSTATUS cmd_lsa_set_secret(struct rpc_pipe_client *cli,
1835 TALLOC_CTX *mem_ctx, int argc,
1836 const char **argv)
1838 NTSTATUS status, result;
1839 struct policy_handle handle, sec_handle;
1840 struct lsa_String name;
1841 struct lsa_DATA_BUF new_val;
1842 struct lsa_DATA_BUF old_val;
1843 DATA_BLOB enc_key;
1844 DATA_BLOB session_key;
1845 struct dcerpc_binding_handle *b = cli->binding_handle;
1847 if (argc < 3) {
1848 printf("Usage: %s name secret\n", argv[0]);
1849 return NT_STATUS_OK;
1852 status = rpccli_lsa_open_policy2(cli, mem_ctx,
1853 true,
1854 SEC_FLAG_MAXIMUM_ALLOWED,
1855 &handle);
1856 if (!NT_STATUS_IS_OK(status)) {
1857 return status;
1860 init_lsa_String(&name, argv[1]);
1862 status = dcerpc_lsa_OpenSecret(b, mem_ctx,
1863 &handle,
1864 name,
1865 SEC_FLAG_MAXIMUM_ALLOWED,
1866 &sec_handle,
1867 &result);
1868 if (!NT_STATUS_IS_OK(status)) {
1869 goto done;
1871 if (!NT_STATUS_IS_OK(result)) {
1872 status = result;
1873 goto done;
1876 ZERO_STRUCT(new_val);
1877 ZERO_STRUCT(old_val);
1879 status = cli_get_session_key(mem_ctx, cli, &session_key);
1880 if (!NT_STATUS_IS_OK(status)) {
1881 goto done;
1884 enc_key = sess_encrypt_string(argv[2], &session_key);
1886 new_val.length = enc_key.length;
1887 new_val.size = enc_key.length;
1888 new_val.data = enc_key.data;
1890 status = dcerpc_lsa_SetSecret(b, mem_ctx,
1891 &sec_handle,
1892 &new_val,
1893 NULL,
1894 &result);
1895 if (!NT_STATUS_IS_OK(status)) {
1896 goto done;
1898 if (!NT_STATUS_IS_OK(result)) {
1899 status = result;
1900 goto done;
1903 done:
1904 if (is_valid_policy_hnd(&sec_handle)) {
1905 dcerpc_lsa_Close(b, mem_ctx, &sec_handle, &result);
1907 if (is_valid_policy_hnd(&handle)) {
1908 dcerpc_lsa_Close(b, mem_ctx, &handle, &result);
1911 return status;
1914 static NTSTATUS cmd_lsa_retrieve_private_data(struct rpc_pipe_client *cli,
1915 TALLOC_CTX *mem_ctx, int argc,
1916 const char **argv)
1918 NTSTATUS status, result;
1919 struct policy_handle handle;
1920 struct lsa_String name;
1921 struct lsa_DATA_BUF *val;
1922 DATA_BLOB session_key;
1923 DATA_BLOB blob = data_blob_null;
1924 char *secret;
1925 struct dcerpc_binding_handle *b = cli->binding_handle;
1927 if (argc < 2) {
1928 printf("Usage: %s name\n", argv[0]);
1929 return NT_STATUS_OK;
1932 status = rpccli_lsa_open_policy2(cli, mem_ctx,
1933 true,
1934 SEC_FLAG_MAXIMUM_ALLOWED,
1935 &handle);
1936 if (!NT_STATUS_IS_OK(status)) {
1937 return status;
1940 init_lsa_String(&name, argv[1]);
1942 ZERO_STRUCT(val);
1944 status = dcerpc_lsa_RetrievePrivateData(b, mem_ctx,
1945 &handle,
1946 &name,
1947 &val,
1948 &result);
1949 if (!NT_STATUS_IS_OK(status)) {
1950 goto done;
1952 if (!NT_STATUS_IS_OK(result)) {
1953 status = result;
1954 goto done;
1957 status = cli_get_session_key(mem_ctx, cli, &session_key);
1958 if (!NT_STATUS_IS_OK(status)) {
1959 goto done;
1962 if (val) {
1963 blob = data_blob_const(val->data, val->length);
1966 secret = sess_decrypt_string(mem_ctx, &blob, &session_key);
1967 if (secret) {
1968 d_printf("secret: %s\n", secret);
1971 done:
1972 if (is_valid_policy_hnd(&handle)) {
1973 dcerpc_lsa_Close(b, mem_ctx, &handle, &result);
1976 return status;
1979 static NTSTATUS cmd_lsa_store_private_data(struct rpc_pipe_client *cli,
1980 TALLOC_CTX *mem_ctx, int argc,
1981 const char **argv)
1983 NTSTATUS status, result;
1984 struct policy_handle handle;
1985 struct lsa_String name;
1986 struct lsa_DATA_BUF val;
1987 DATA_BLOB session_key;
1988 DATA_BLOB enc_key;
1989 struct dcerpc_binding_handle *b = cli->binding_handle;
1991 if (argc < 3) {
1992 printf("Usage: %s name secret\n", argv[0]);
1993 return NT_STATUS_OK;
1996 status = rpccli_lsa_open_policy2(cli, mem_ctx,
1997 true,
1998 SEC_FLAG_MAXIMUM_ALLOWED,
1999 &handle);
2000 if (!NT_STATUS_IS_OK(status)) {
2001 return status;
2004 init_lsa_String(&name, argv[1]);
2006 ZERO_STRUCT(val);
2008 status = cli_get_session_key(mem_ctx, cli, &session_key);
2009 if (!NT_STATUS_IS_OK(status)) {
2010 goto done;
2013 enc_key = sess_encrypt_string(argv[2], &session_key);
2015 val.length = enc_key.length;
2016 val.size = enc_key.length;
2017 val.data = enc_key.data;
2019 status = dcerpc_lsa_StorePrivateData(b, mem_ctx,
2020 &handle,
2021 &name,
2022 &val,
2023 &result);
2024 if (!NT_STATUS_IS_OK(status)) {
2025 goto done;
2027 if (!NT_STATUS_IS_OK(result)) {
2028 status = result;
2029 goto done;
2032 done:
2033 if (is_valid_policy_hnd(&handle)) {
2034 dcerpc_lsa_Close(b, mem_ctx, &handle, &result);
2037 return status;
2040 static NTSTATUS cmd_lsa_create_trusted_domain(struct rpc_pipe_client *cli,
2041 TALLOC_CTX *mem_ctx, int argc,
2042 const char **argv)
2044 NTSTATUS status, result;
2045 struct policy_handle handle, trustdom_handle;
2046 struct dom_sid sid;
2047 struct lsa_DomainInfo info;
2048 struct dcerpc_binding_handle *b = cli->binding_handle;
2050 if (argc < 3) {
2051 printf("Usage: %s name sid\n", argv[0]);
2052 return NT_STATUS_OK;
2055 status = rpccli_lsa_open_policy2(cli, mem_ctx,
2056 true,
2057 SEC_FLAG_MAXIMUM_ALLOWED,
2058 &handle);
2059 if (!NT_STATUS_IS_OK(status)) {
2060 return status;
2063 init_lsa_StringLarge(&info.name, argv[1]);
2064 info.sid = &sid;
2065 string_to_sid(&sid, argv[2]);
2067 status = dcerpc_lsa_CreateTrustedDomain(b, mem_ctx,
2068 &handle,
2069 &info,
2070 SEC_FLAG_MAXIMUM_ALLOWED,
2071 &trustdom_handle,
2072 &result);
2073 if (!NT_STATUS_IS_OK(status)) {
2074 goto done;
2076 if (!NT_STATUS_IS_OK(result)) {
2077 status = result;
2078 goto done;
2081 done:
2082 if (is_valid_policy_hnd(&trustdom_handle)) {
2083 dcerpc_lsa_Close(b, mem_ctx, &trustdom_handle, &result);
2086 if (is_valid_policy_hnd(&handle)) {
2087 dcerpc_lsa_Close(b, mem_ctx, &handle, &result);
2090 return status;
2093 static NTSTATUS cmd_lsa_delete_trusted_domain(struct rpc_pipe_client *cli,
2094 TALLOC_CTX *mem_ctx, int argc,
2095 const char **argv)
2097 NTSTATUS status, result;
2098 struct policy_handle handle, trustdom_handle;
2099 struct lsa_String name;
2100 struct dom_sid *sid = NULL;
2101 struct dcerpc_binding_handle *b = cli->binding_handle;
2103 if (argc < 2) {
2104 printf("Usage: %s name\n", argv[0]);
2105 return NT_STATUS_OK;
2108 status = rpccli_lsa_open_policy2(cli, mem_ctx,
2109 true,
2110 SEC_FLAG_MAXIMUM_ALLOWED,
2111 &handle);
2112 if (!NT_STATUS_IS_OK(status)) {
2113 return status;
2116 init_lsa_String(&name, argv[1]);
2118 status = dcerpc_lsa_OpenTrustedDomainByName(b, mem_ctx,
2119 &handle,
2120 name,
2121 SEC_FLAG_MAXIMUM_ALLOWED,
2122 &trustdom_handle,
2123 &result);
2124 if (NT_STATUS_IS_OK(status) && NT_STATUS_IS_OK(result)) {
2125 goto delete_object;
2129 uint32_t resume_handle = 0;
2130 struct lsa_DomainList domains;
2131 int i;
2133 status = dcerpc_lsa_EnumTrustDom(b, mem_ctx,
2134 &handle,
2135 &resume_handle,
2136 &domains,
2137 0xffff,
2138 &result);
2139 if (!NT_STATUS_IS_OK(status)) {
2140 goto done;
2142 if (!NT_STATUS_IS_OK(result)) {
2143 status = result;
2144 goto done;
2147 for (i=0; i < domains.count; i++) {
2148 if (strequal(domains.domains[i].name.string, argv[1])) {
2149 sid = domains.domains[i].sid;
2150 break;
2154 if (!sid) {
2155 return NT_STATUS_INVALID_SID;
2159 status = dcerpc_lsa_OpenTrustedDomain(b, mem_ctx,
2160 &handle,
2161 sid,
2162 SEC_FLAG_MAXIMUM_ALLOWED,
2163 &trustdom_handle,
2164 &result);
2165 if (!NT_STATUS_IS_OK(status)) {
2166 goto done;
2168 if (!NT_STATUS_IS_OK(result)) {
2169 status = result;
2170 goto done;
2173 delete_object:
2174 status = dcerpc_lsa_DeleteObject(b, mem_ctx,
2175 &trustdom_handle,
2176 &result);
2177 if (!NT_STATUS_IS_OK(status)) {
2178 goto done;
2180 if (!NT_STATUS_IS_OK(result)) {
2181 status = result;
2182 goto done;
2185 done:
2186 if (is_valid_policy_hnd(&trustdom_handle)) {
2187 dcerpc_lsa_Close(b, mem_ctx, &trustdom_handle, &result);
2190 if (is_valid_policy_hnd(&handle)) {
2191 dcerpc_lsa_Close(b, mem_ctx, &handle, &result);
2194 return status;
2198 /* List of commands exported by this module */
2200 struct cmd_set lsarpc_commands[] = {
2202 { "LSARPC" },
2204 { "lsaquery", RPC_RTYPE_NTSTATUS, cmd_lsa_query_info_policy, NULL, &ndr_table_lsarpc.syntax_id, NULL, "Query info policy", "" },
2205 { "lookupsids", RPC_RTYPE_NTSTATUS, cmd_lsa_lookup_sids, NULL, &ndr_table_lsarpc.syntax_id, NULL, "Convert SIDs to names", "" },
2206 { "lookupsids3", RPC_RTYPE_NTSTATUS, cmd_lsa_lookup_sids3, NULL, &ndr_table_lsarpc.syntax_id, NULL, "Convert SIDs to names", "" },
2207 { "lookupnames", RPC_RTYPE_NTSTATUS, cmd_lsa_lookup_names, NULL, &ndr_table_lsarpc.syntax_id, NULL, "Convert names to SIDs", "" },
2208 { "lookupnames4", RPC_RTYPE_NTSTATUS, cmd_lsa_lookup_names4, NULL, &ndr_table_lsarpc.syntax_id, NULL, "Convert names to SIDs", "" },
2209 { "lookupnames_level", RPC_RTYPE_NTSTATUS, cmd_lsa_lookup_names_level, NULL, &ndr_table_lsarpc.syntax_id, NULL, "Convert names to SIDs", "" },
2210 { "enumtrust", RPC_RTYPE_NTSTATUS, cmd_lsa_enum_trust_dom, NULL, &ndr_table_lsarpc.syntax_id, NULL, "Enumerate trusted domains", "Usage: [preferred max number] [enum context (0)]" },
2211 { "enumprivs", RPC_RTYPE_NTSTATUS, cmd_lsa_enum_privilege, NULL, &ndr_table_lsarpc.syntax_id, NULL, "Enumerate privileges", "" },
2212 { "getdispname", RPC_RTYPE_NTSTATUS, cmd_lsa_get_dispname, NULL, &ndr_table_lsarpc.syntax_id, NULL, "Get the privilege name", "" },
2213 { "lsaenumsid", RPC_RTYPE_NTSTATUS, cmd_lsa_enum_sids, NULL, &ndr_table_lsarpc.syntax_id, NULL, "Enumerate the LSA SIDS", "" },
2214 { "lsacreateaccount", RPC_RTYPE_NTSTATUS, cmd_lsa_create_account, NULL, &ndr_table_lsarpc.syntax_id, NULL, "Create a new lsa account", "" },
2215 { "lsaenumprivsaccount", RPC_RTYPE_NTSTATUS, cmd_lsa_enum_privsaccounts, NULL, &ndr_table_lsarpc.syntax_id, NULL, "Enumerate the privileges of an SID", "" },
2216 { "lsaenumacctrights", RPC_RTYPE_NTSTATUS, cmd_lsa_enum_acct_rights, NULL, &ndr_table_lsarpc.syntax_id, NULL, "Enumerate the rights of an SID", "" },
2217 { "lsaaddpriv", RPC_RTYPE_NTSTATUS, cmd_lsa_add_priv, NULL, &ndr_table_lsarpc.syntax_id, NULL, "Assign a privilege to a SID", "" },
2218 { "lsadelpriv", RPC_RTYPE_NTSTATUS, cmd_lsa_del_priv, NULL, &ndr_table_lsarpc.syntax_id, NULL, "Revoke a privilege from a SID", "" },
2219 { "lsaaddacctrights", RPC_RTYPE_NTSTATUS, cmd_lsa_add_acct_rights, NULL, &ndr_table_lsarpc.syntax_id, NULL, "Add rights to an account", "" },
2220 { "lsaremoveacctrights", RPC_RTYPE_NTSTATUS, cmd_lsa_remove_acct_rights, NULL, &ndr_table_lsarpc.syntax_id, NULL, "Remove rights from an account", "" },
2221 { "lsalookupprivvalue", RPC_RTYPE_NTSTATUS, cmd_lsa_lookup_priv_value, NULL, &ndr_table_lsarpc.syntax_id, NULL, "Get a privilege value given its name", "" },
2222 { "lsaquerysecobj", RPC_RTYPE_NTSTATUS, cmd_lsa_query_secobj, NULL, &ndr_table_lsarpc.syntax_id, NULL, "Query LSA security object", "" },
2223 { "lsaquerytrustdominfo",RPC_RTYPE_NTSTATUS, cmd_lsa_query_trustdominfo, NULL, &ndr_table_lsarpc.syntax_id, NULL, "Query LSA trusted domains info (given a SID)", "" },
2224 { "lsaquerytrustdominfobyname",RPC_RTYPE_NTSTATUS, cmd_lsa_query_trustdominfobyname, NULL, &ndr_table_lsarpc.syntax_id, NULL, "Query LSA trusted domains info (given a name), only works for Windows > 2k", "" },
2225 { "lsaquerytrustdominfobysid",RPC_RTYPE_NTSTATUS, cmd_lsa_query_trustdominfobysid, NULL, &ndr_table_lsarpc.syntax_id, NULL, "Query LSA trusted domains info (given a SID)", "" },
2226 { "getusername", RPC_RTYPE_NTSTATUS, cmd_lsa_get_username, NULL, &ndr_table_lsarpc.syntax_id, NULL, "Get username", "" },
2227 { "createsecret", RPC_RTYPE_NTSTATUS, cmd_lsa_create_secret, NULL, &ndr_table_lsarpc.syntax_id, NULL, "Create Secret", "" },
2228 { "deletesecret", RPC_RTYPE_NTSTATUS, cmd_lsa_delete_secret, NULL, &ndr_table_lsarpc.syntax_id, NULL, "Delete Secret", "" },
2229 { "querysecret", RPC_RTYPE_NTSTATUS, cmd_lsa_query_secret, NULL, &ndr_table_lsarpc.syntax_id, NULL, "Query Secret", "" },
2230 { "setsecret", RPC_RTYPE_NTSTATUS, cmd_lsa_set_secret, NULL, &ndr_table_lsarpc.syntax_id, NULL, "Set Secret", "" },
2231 { "retrieveprivatedata", RPC_RTYPE_NTSTATUS, cmd_lsa_retrieve_private_data, NULL, &ndr_table_lsarpc.syntax_id, NULL, "Retrieve Private Data", "" },
2232 { "storeprivatedata", RPC_RTYPE_NTSTATUS, cmd_lsa_store_private_data, NULL, &ndr_table_lsarpc.syntax_id, NULL, "Store Private Data", "" },
2233 { "createtrustdom", RPC_RTYPE_NTSTATUS, cmd_lsa_create_trusted_domain, NULL, &ndr_table_lsarpc.syntax_id, NULL, "Create Trusted Domain", "" },
2234 { "deletetrustdom", RPC_RTYPE_NTSTATUS, cmd_lsa_delete_trusted_domain, NULL, &ndr_table_lsarpc.syntax_id, NULL, "Delete Trusted Domain", "" },
2236 { NULL }