libnet: Fix Coverity ID 1634803 Dereference after null check
[Samba.git] / source3 / rpcclient / cmd_lsarpc.c
bloba5693504cddb63f765af172e14011d135fc34293
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 "../libcli/auth/libcli_auth.h"
26 #include "../librpc/gen_ndr/ndr_lsa.h"
27 #include "../librpc/gen_ndr/ndr_lsa_c.h"
28 #include "rpc_client/cli_lsarpc.h"
29 #include "rpc_client/init_lsa.h"
30 #include "../libcli/security/security.h"
32 /* useful function to allow entering a name instead of a SID and
33 * looking it up automatically */
34 static NTSTATUS name_to_sid(struct rpc_pipe_client *cli,
35 TALLOC_CTX *mem_ctx,
36 struct dom_sid *sid,
37 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 struct dom_sid_buf buf;
95 d_printf("Domain Name: %s\n", r->name.string);
96 d_printf("Domain Sid: %s\n", dom_sid_str_buf(r->sid, &buf));
99 static void display_query_info_5(struct lsa_DomainInfo *r)
101 struct dom_sid_buf buf;
102 d_printf("Domain Name: %s\n", r->name.string);
103 d_printf("Domain Sid: %s\n", dom_sid_str_buf(r->sid, &buf));
106 static void display_query_info_10(struct lsa_AuditFullSetInfo *r)
108 d_printf("Shutdown on full: %d\n", r->shutdown_on_full);
111 static void display_query_info_11(struct lsa_AuditFullQueryInfo *r)
113 d_printf("Shutdown on full: %d\n", r->shutdown_on_full);
114 d_printf("Log is full: %d\n", r->log_is_full);
117 static void display_query_info_12(struct lsa_DnsDomainInfo *r)
119 struct dom_sid_buf buf;
120 d_printf("Domain NetBios Name: %s\n", r->name.string);
121 d_printf("Domain DNS Name: %s\n", r->dns_domain.string);
122 d_printf("Domain Forest Name: %s\n", r->dns_forest.string);
123 d_printf("Domain Sid: %s\n", dom_sid_str_buf(r->sid, &buf));
124 d_printf("Domain GUID: %s\n", GUID_string(talloc_tos(),
125 &r->domain_guid));
128 static void display_lsa_query_info(union lsa_PolicyInformation *info,
129 enum lsa_PolicyInfo level)
131 switch (level) {
132 case 1:
133 display_query_info_1(&info->audit_log);
134 break;
135 case 2:
136 display_query_info_2(&info->audit_events);
137 break;
138 case 3:
139 display_query_info_3(&info->domain);
140 break;
141 case 5:
142 display_query_info_5(&info->account_domain);
143 break;
144 case 10:
145 display_query_info_10(&info->auditfullset);
146 break;
147 case 11:
148 display_query_info_11(&info->auditfullquery);
149 break;
150 case 12:
151 display_query_info_12(&info->dns);
152 break;
153 default:
154 printf("can't display info level: %d\n", level);
155 break;
159 static NTSTATUS cmd_lsa_query_info_policy(struct rpc_pipe_client *cli,
160 TALLOC_CTX *mem_ctx,
161 int argc,
162 const char **argv)
164 struct policy_handle pol;
165 NTSTATUS status, result;
166 union lsa_PolicyInformation *info = NULL;
167 struct dcerpc_binding_handle *b = cli->binding_handle;
169 uint32_t info_class = 3;
171 if (argc > 2) {
172 printf("Usage: %s [info_class]\n", argv[0]);
173 return NT_STATUS_OK;
176 if (argc == 2)
177 info_class = atoi(argv[1]);
179 switch (info_class) {
180 case 12: {
181 union lsa_revision_info out_revision_info = {
182 .info1 = {
183 .revision = 0,
186 uint32_t out_version = 0;
188 status = dcerpc_lsa_open_policy_fallback(
190 mem_ctx,
191 cli->srv_name_slash,
192 true,
193 SEC_FLAG_MAXIMUM_ALLOWED,
194 &out_version,
195 &out_revision_info,
196 &pol,
197 &result);
198 if (any_nt_status_not_ok(status, result, &status)) {
199 goto done;
202 status = dcerpc_lsa_QueryInfoPolicy2(b, mem_ctx,
203 &pol,
204 info_class,
205 &info,
206 &result);
207 break;
209 default:
210 status = rpccli_lsa_open_policy(cli, mem_ctx, True,
211 SEC_FLAG_MAXIMUM_ALLOWED,
212 &pol);
214 if (!NT_STATUS_IS_OK(status))
215 goto done;
217 status = dcerpc_lsa_QueryInfoPolicy(b, mem_ctx,
218 &pol,
219 info_class,
220 &info,
221 &result);
224 if (!NT_STATUS_IS_OK(status)) {
225 goto done;
227 status = result;
228 if (NT_STATUS_IS_OK(result)) {
229 display_lsa_query_info(info, info_class);
232 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
234 done:
235 return status;
238 /* Resolve a list of names to a list of sids */
240 static NTSTATUS cmd_lsa_lookup_names(struct rpc_pipe_client *cli,
241 TALLOC_CTX *mem_ctx,
242 int argc,
243 const char **argv)
245 struct policy_handle pol;
246 NTSTATUS status, result;
247 struct dom_sid *sids;
248 enum lsa_SidType *types;
249 int i;
250 struct dcerpc_binding_handle *b = cli->binding_handle;
252 if (argc == 1) {
253 printf("Usage: %s [name1 [name2 [...]]]\n", argv[0]);
254 return NT_STATUS_OK;
257 status = rpccli_lsa_open_policy(cli, mem_ctx, True,
258 LSA_POLICY_LOOKUP_NAMES,
259 &pol);
261 if (!NT_STATUS_IS_OK(status))
262 goto done;
264 status = rpccli_lsa_lookup_names(cli, mem_ctx, &pol, argc - 1,
265 (const char**)(argv + 1), NULL, 1, &sids, &types);
267 if (!NT_STATUS_IS_OK(status) && NT_STATUS_V(status) !=
268 NT_STATUS_V(STATUS_SOME_UNMAPPED))
269 goto done;
271 status = NT_STATUS_OK;
273 /* Print results */
275 for (i = 0; i < (argc - 1); i++) {
276 struct dom_sid_buf sid_str;
277 printf("%s %s (%s: %d)\n",
278 argv[i + 1],
279 dom_sid_str_buf(&sids[i], &sid_str),
280 sid_type_lookup(types[i]),
281 types[i]);
284 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
286 done:
287 return status;
290 /* Resolve a list of names to a list of sids */
292 static NTSTATUS cmd_lsa_lookup_names_level(struct rpc_pipe_client *cli,
293 TALLOC_CTX *mem_ctx,
294 int argc,
295 const char **argv)
297 struct policy_handle pol;
298 NTSTATUS status, result;
299 struct dom_sid *sids = NULL;
300 enum lsa_SidType *types = NULL;
301 int i, level;
302 struct dcerpc_binding_handle *b = cli->binding_handle;
304 if (argc < 3) {
305 printf("Usage: %s [level] [name1 [name2 [...]]]\n", argv[0]);
306 return NT_STATUS_OK;
309 status = rpccli_lsa_open_policy(cli, mem_ctx, True,
310 LSA_POLICY_LOOKUP_NAMES,
311 &pol);
312 if (!NT_STATUS_IS_OK(status)) {
313 goto done;
316 level = atoi(argv[1]);
318 status = rpccli_lsa_lookup_names(cli, mem_ctx, &pol, argc - 2,
319 (const char**)(argv + 2), NULL, level, &sids, &types);
321 if (!NT_STATUS_IS_OK(status) && NT_STATUS_V(status) !=
322 NT_STATUS_V(STATUS_SOME_UNMAPPED))
324 goto done;
327 status = NT_STATUS_OK;
329 /* Print results */
331 for (i = 0; i < (argc - 2); i++) {
332 struct dom_sid_buf sid_str;
333 printf("%s %s (%s: %d)\n",
334 argv[i + 2],
335 dom_sid_str_buf(&sids[i], &sid_str),
336 sid_type_lookup(types[i]),
337 types[i]);
340 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
342 done:
343 return status;
346 static NTSTATUS cmd_lsa_lookup_names4(struct rpc_pipe_client *cli,
347 TALLOC_CTX *mem_ctx, int argc,
348 const char **argv)
350 NTSTATUS status, result;
352 uint32_t num_names;
353 struct lsa_String *names;
354 struct lsa_RefDomainList *domains = NULL;
355 struct lsa_TransSidArray3 sids;
356 uint32_t count = 0;
357 int i;
358 struct dcerpc_binding_handle *b = cli->binding_handle;
360 if (argc == 1) {
361 printf("Usage: %s [name1 [name2 [...]]]\n", argv[0]);
362 return NT_STATUS_OK;
365 ZERO_STRUCT(sids);
367 num_names = argc-1;
368 names = talloc_array(mem_ctx, struct lsa_String, num_names);
369 NT_STATUS_HAVE_NO_MEMORY(names);
371 for (i=0; i < num_names; i++) {
372 init_lsa_String(&names[i], argv[i+1]);
375 status = dcerpc_lsa_LookupNames4(b, mem_ctx,
376 num_names,
377 names,
378 &domains,
379 &sids,
381 &count,
384 &result);
385 if (!NT_STATUS_IS_OK(status)) {
386 return status;
388 if (!NT_STATUS_IS_OK(result)) {
389 return result;
392 if (sids.count != num_names) {
393 return NT_STATUS_INVALID_NETWORK_RESPONSE;
396 for (i = 0; i < sids.count; i++) {
397 struct dom_sid_buf sid_str;
398 printf("%s %s (%s: %d)\n",
399 argv[i+1],
400 dom_sid_str_buf(sids.sids[i].sid, &sid_str),
401 sid_type_lookup(sids.sids[i].sid_type),
402 sids.sids[i].sid_type);
405 return status;
408 /* Resolve a list of SIDs to a list of names */
410 static NTSTATUS cmd_lsa_lookup_sids(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
411 int argc, const char **argv)
413 struct policy_handle pol;
414 NTSTATUS status, result;
415 struct dom_sid *sids;
416 char **domains;
417 char **names;
418 enum lsa_SidType *types;
419 int i;
420 struct dcerpc_binding_handle *b = cli->binding_handle;
422 if (argc == 1) {
423 printf("Usage: %s [sid1 [sid2 [...]]]\n", argv[0]);
424 return NT_STATUS_OK;
427 status = rpccli_lsa_open_policy(cli, mem_ctx, True,
428 LSA_POLICY_LOOKUP_NAMES,
429 &pol);
431 if (!NT_STATUS_IS_OK(status))
432 goto done;
434 /* Convert arguments to sids */
436 sids = talloc_array(mem_ctx, struct dom_sid, argc - 1);
438 if (!sids) {
439 printf("could not allocate memory for %d sids\n", argc - 1);
440 goto done;
443 for (i = 0; i < argc - 1; i++)
444 if (!string_to_sid(&sids[i], argv[i + 1])) {
445 status = NT_STATUS_INVALID_SID;
446 goto done;
449 /* Lookup the SIDs */
451 status = rpccli_lsa_lookup_sids(cli, mem_ctx, &pol, argc - 1, sids,
452 &domains, &names, &types);
454 if (!NT_STATUS_IS_OK(status) && NT_STATUS_V(status) !=
455 NT_STATUS_V(STATUS_SOME_UNMAPPED))
456 goto done;
458 status = NT_STATUS_OK;
460 /* Print results */
462 for (i = 0; i < (argc - 1); i++) {
463 struct dom_sid_buf sid_str;
465 dom_sid_str_buf(&sids[i], &sid_str);
466 if (types[i] == SID_NAME_DOMAIN) {
467 printf("%s %s (%d)\n", sid_str.buf,
468 domains[i] ? domains[i] : "*unknown*",
469 types[i]);
470 } else {
471 printf("%s %s\\%s (%d)\n", sid_str.buf,
472 domains[i] ? domains[i] : "*unknown*",
473 names[i] ? names[i] : "*unknown*",
474 types[i]);
478 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
480 done:
481 return status;
484 static NTSTATUS cmd_lsa_lookup_sids_level(struct rpc_pipe_client *cli,
485 TALLOC_CTX *mem_ctx, int argc,
486 const char **argv)
488 struct policy_handle pol;
489 NTSTATUS status, result;
490 struct dom_sid *sids = NULL;
491 char **domains = NULL;
492 char **names = NULL;
493 enum lsa_SidType *types = NULL;
494 int i, level;
495 struct dcerpc_binding_handle *b = cli->binding_handle;
497 if (argc < 3) {
498 printf("Usage: %s [level] [sid1 [sid2 [...]]]\n", argv[0]);
499 return NT_STATUS_OK;
502 status = rpccli_lsa_open_policy(cli, mem_ctx, True,
503 LSA_POLICY_LOOKUP_NAMES,
504 &pol);
505 if (!NT_STATUS_IS_OK(status)) {
506 goto done;
509 level = atoi(argv[1]);
511 /* Convert arguments to sids */
513 sids = talloc_array(mem_ctx, struct dom_sid, argc - 2);
514 if (sids == NULL) {
515 printf("could not allocate memory for %d sids\n", argc - 2);
516 goto done;
519 for (i = 0; i < argc - 2; i++) {
520 if (!string_to_sid(&sids[i], argv[i + 2])) {
521 status = NT_STATUS_INVALID_SID;
522 goto done;
526 /* Lookup the SIDs */
528 status = dcerpc_lsa_lookup_sids_generic(cli->binding_handle,
529 mem_ctx,
530 &pol,
531 argc - 2,
532 sids,
533 level,
534 &domains,
535 &names,
536 &types,
537 false,
538 &result);
539 if (!NT_STATUS_IS_OK(status)) {
540 goto done;
542 status = result;
544 if (!NT_STATUS_IS_OK(status) && NT_STATUS_V(status) !=
545 NT_STATUS_V(STATUS_SOME_UNMAPPED))
547 goto done;
550 status = NT_STATUS_OK;
552 /* Print results */
554 for (i = 0; i < (argc - 2); i++) {
555 struct dom_sid_buf sid_str;
557 dom_sid_str_buf(&sids[i], &sid_str);
558 if (types[i] == SID_NAME_DOMAIN) {
559 printf("%s %s (%d)\n", sid_str.buf,
560 domains[i] ? domains[i] : "*unknown*",
561 types[i]);
562 } else {
563 printf("%s %s\\%s (%d)\n", sid_str.buf,
564 domains[i] ? domains[i] : "*unknown*",
565 names[i] ? names[i] : "*unknown*",
566 types[i]);
570 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
572 done:
573 return status;
576 /* Resolve a list of SIDs to a list of names */
578 static NTSTATUS cmd_lsa_lookup_sids3(struct rpc_pipe_client *cli,
579 TALLOC_CTX *mem_ctx,
580 int argc, const char **argv)
582 NTSTATUS status = NT_STATUS_UNSUCCESSFUL, result;
583 int i;
584 struct lsa_SidArray sids;
585 struct lsa_RefDomainList *domains = NULL;
586 struct lsa_TransNameArray2 names;
587 uint32_t count = 0;
588 struct dcerpc_binding_handle *b = cli->binding_handle;
590 if (argc == 1) {
591 printf("Usage: %s [sid1 [sid2 [...]]]\n", argv[0]);
592 return NT_STATUS_OK;
595 ZERO_STRUCT(names);
597 /* Convert arguments to sids */
599 sids.num_sids = argc-1;
600 sids.sids = talloc_array(mem_ctx, struct lsa_SidPtr, sids.num_sids);
601 if (!sids.sids) {
602 printf("could not allocate memory for %d sids\n", sids.num_sids);
603 goto done;
606 for (i = 0; i < sids.num_sids; i++) {
607 sids.sids[i].sid = talloc(sids.sids, struct dom_sid);
608 if (sids.sids[i].sid == NULL) {
609 status = NT_STATUS_NO_MEMORY;
610 goto done;
612 if (!string_to_sid(sids.sids[i].sid, argv[i+1])) {
613 status = NT_STATUS_INVALID_SID;
614 goto done;
618 /* Lookup the SIDs */
619 status = dcerpc_lsa_LookupSids3(b, mem_ctx,
620 &sids,
621 &domains,
622 &names,
624 &count,
627 &result);
628 if (!NT_STATUS_IS_OK(status)) {
629 goto done;
631 if (!NT_STATUS_IS_OK(result) && NT_STATUS_V(result) !=
632 NT_STATUS_V(STATUS_SOME_UNMAPPED)) {
633 status = result;
634 goto done;
637 status = NT_STATUS_OK;
639 /* Print results */
641 for (i = 0; i < names.count; i++) {
642 struct dom_sid_buf sid_str;
644 if (i >= sids.num_sids) {
645 break;
647 printf("%s %s (%d)\n",
648 dom_sid_str_buf(sids.sids[i].sid, &sid_str),
649 names.names[i].name.string,
650 names.names[i].sid_type);
653 done:
654 return status;
658 /* Enumerate list of trusted domains */
660 static NTSTATUS cmd_lsa_enum_trust_dom(struct rpc_pipe_client *cli,
661 TALLOC_CTX *mem_ctx,
662 int argc,
663 const char **argv)
665 struct policy_handle pol;
666 NTSTATUS status, result;
667 struct lsa_DomainList domain_list;
668 struct dcerpc_binding_handle *b = cli->binding_handle;
670 /* defaults, but may be changed using params */
671 uint32_t enum_ctx = 0;
672 int i;
673 uint32_t max_size = (uint32_t)-1;
675 if (argc > 2) {
676 printf("Usage: %s [enum context (0)]\n", argv[0]);
677 return NT_STATUS_OK;
680 if (argc == 2 && argv[1]) {
681 enum_ctx = atoi(argv[2]);
684 status = rpccli_lsa_open_policy(cli, mem_ctx, True,
685 LSA_POLICY_VIEW_LOCAL_INFORMATION,
686 &pol);
688 if (!NT_STATUS_IS_OK(status))
689 goto done;
691 status = STATUS_MORE_ENTRIES;
693 while (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) {
695 /* Lookup list of trusted domains */
697 status = dcerpc_lsa_EnumTrustDom(b, mem_ctx,
698 &pol,
699 &enum_ctx,
700 &domain_list,
701 max_size,
702 &result);
703 if (!NT_STATUS_IS_OK(status)) {
704 goto done;
706 if (!NT_STATUS_IS_OK(result) &&
707 !NT_STATUS_EQUAL(result, NT_STATUS_NO_MORE_ENTRIES) &&
708 !NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)) {
709 status = result;
710 goto done;
713 /* Print results: list of names and sids returned in this
714 * response. */
715 for (i = 0; i < domain_list.count; i++) {
716 struct dom_sid_buf sid_str;
718 printf("%s %s\n",
719 domain_list.domains[i].name.string ?
720 domain_list.domains[i].name.string : "*unknown*",
721 dom_sid_str_buf(domain_list.domains[i].sid,
722 &sid_str));
726 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
727 done:
728 return status;
731 /* Enumerates privileges */
733 static NTSTATUS cmd_lsa_enum_privilege(struct rpc_pipe_client *cli,
734 TALLOC_CTX *mem_ctx,
735 int argc,
736 const char **argv)
738 struct policy_handle pol;
739 NTSTATUS status, result;
740 struct lsa_PrivArray priv_array;
741 struct dcerpc_binding_handle *b = cli->binding_handle;
743 uint32_t enum_context=0;
744 uint32_t pref_max_length=0x1000;
745 int i;
747 if (argc > 3) {
748 printf("Usage: %s [enum context] [max length]\n", argv[0]);
749 return NT_STATUS_OK;
752 if (argc>=2)
753 enum_context=atoi(argv[1]);
755 if (argc==3)
756 pref_max_length=atoi(argv[2]);
758 status = rpccli_lsa_open_policy(cli, mem_ctx, True,
759 SEC_FLAG_MAXIMUM_ALLOWED,
760 &pol);
762 if (!NT_STATUS_IS_OK(status))
763 goto done;
765 status = dcerpc_lsa_EnumPrivs(b, mem_ctx,
766 &pol,
767 &enum_context,
768 &priv_array,
769 pref_max_length,
770 &result);
771 if (!NT_STATUS_IS_OK(status))
772 goto done;
773 if (!NT_STATUS_IS_OK(result)) {
774 status = result;
775 goto done;
778 /* Print results */
779 printf("found %d privileges\n\n", priv_array.count);
781 for (i = 0; i < priv_array.count; i++) {
782 printf("%s \t\t%d:%d (0x%x:0x%x)\n",
783 priv_array.privs[i].name.string ? priv_array.privs[i].name.string : "*unknown*",
784 priv_array.privs[i].luid.high,
785 priv_array.privs[i].luid.low,
786 priv_array.privs[i].luid.high,
787 priv_array.privs[i].luid.low);
790 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
791 done:
792 return status;
795 /* Get privilege name */
797 static NTSTATUS cmd_lsa_get_dispname(struct rpc_pipe_client *cli,
798 TALLOC_CTX *mem_ctx,
799 int argc,
800 const char **argv)
802 struct policy_handle pol;
803 NTSTATUS status, result;
804 struct dcerpc_binding_handle *b = cli->binding_handle;
806 uint16_t lang_id=0;
807 uint16_t lang_id_sys=0;
808 uint16_t lang_id_desc;
809 struct lsa_String lsa_name;
810 struct lsa_StringLarge *description = NULL;
812 if (argc != 2) {
813 printf("Usage: %s privilege name\n", argv[0]);
814 return NT_STATUS_OK;
817 status = rpccli_lsa_open_policy(cli, mem_ctx, True,
818 SEC_FLAG_MAXIMUM_ALLOWED,
819 &pol);
821 if (!NT_STATUS_IS_OK(status))
822 goto done;
824 init_lsa_String(&lsa_name, argv[1]);
826 status = dcerpc_lsa_LookupPrivDisplayName(b, mem_ctx,
827 &pol,
828 &lsa_name,
829 lang_id,
830 lang_id_sys,
831 &description,
832 &lang_id_desc,
833 &result);
834 if (!NT_STATUS_IS_OK(status))
835 goto done;
836 if (!NT_STATUS_IS_OK(result)) {
837 status = result;
838 goto done;
841 /* Print results */
842 printf("%s -> %s (language: 0x%x)\n", argv[1], description->string, lang_id_desc);
844 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
845 done:
846 return status;
849 /* Enumerate the LSA SIDS */
851 static NTSTATUS cmd_lsa_enum_sids(struct rpc_pipe_client *cli,
852 TALLOC_CTX *mem_ctx,
853 int argc,
854 const char **argv)
856 struct policy_handle pol;
857 NTSTATUS status, result;
858 struct dcerpc_binding_handle *b = cli->binding_handle;
860 uint32_t enum_context=0;
861 uint32_t pref_max_length=0x1000;
862 struct lsa_SidArray sid_array;
863 int i;
865 if (argc > 3) {
866 printf("Usage: %s [enum context] [max length]\n", argv[0]);
867 return NT_STATUS_OK;
870 if (argc>=2)
871 enum_context=atoi(argv[1]);
873 if (argc==3)
874 pref_max_length=atoi(argv[2]);
876 status = rpccli_lsa_open_policy(cli, mem_ctx, True,
877 SEC_FLAG_MAXIMUM_ALLOWED,
878 &pol);
880 if (!NT_STATUS_IS_OK(status))
881 goto done;
883 status = dcerpc_lsa_EnumAccounts(b, mem_ctx,
884 &pol,
885 &enum_context,
886 &sid_array,
887 pref_max_length,
888 &result);
889 if (!NT_STATUS_IS_OK(status))
890 goto done;
891 if (!NT_STATUS_IS_OK(result)) {
892 status = result;
893 goto done;
896 /* Print results */
897 printf("found %d SIDs\n\n", sid_array.num_sids);
899 for (i = 0; i < sid_array.num_sids; i++) {
900 struct dom_sid_buf sid_str;
902 printf("%s\n",
903 dom_sid_str_buf(sid_array.sids[i].sid, &sid_str));
906 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
907 done:
908 return status;
911 /* Create a new account */
913 static NTSTATUS cmd_lsa_create_account(struct rpc_pipe_client *cli,
914 TALLOC_CTX *mem_ctx,
915 int argc,
916 const char **argv)
918 struct policy_handle dom_pol;
919 struct policy_handle user_pol;
920 NTSTATUS status, result;
921 uint32_t des_access = 0x000f000f;
922 struct dcerpc_binding_handle *b = cli->binding_handle;
923 union lsa_revision_info out_revision_info = {
924 .info1 = {
925 .revision = 0,
928 uint32_t out_version = 0;
930 struct dom_sid sid;
932 if (argc != 2 ) {
933 printf("Usage: %s SID\n", argv[0]);
934 return NT_STATUS_OK;
937 status = name_to_sid(cli, mem_ctx, &sid, argv[1]);
938 if (!NT_STATUS_IS_OK(status))
939 goto done;
941 status = dcerpc_lsa_open_policy_fallback(b,
942 mem_ctx,
943 cli->srv_name_slash,
944 true,
945 SEC_FLAG_MAXIMUM_ALLOWED,
946 &out_version,
947 &out_revision_info,
948 &dom_pol,
949 &result);
950 if (any_nt_status_not_ok(status, result, &status)) {
951 goto done;
954 status = dcerpc_lsa_CreateAccount(b, mem_ctx,
955 &dom_pol,
956 &sid,
957 des_access,
958 &user_pol,
959 &result);
960 if (!NT_STATUS_IS_OK(status))
961 goto done;
962 if (!NT_STATUS_IS_OK(result)) {
963 status = result;
964 goto done;
967 printf("Account for SID %s successfully created\n\n", argv[1]);
968 status = NT_STATUS_OK;
970 dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result);
971 done:
972 return status;
976 /* Enumerate the privileges of an SID */
978 static NTSTATUS cmd_lsa_enum_privsaccounts(struct rpc_pipe_client *cli,
979 TALLOC_CTX *mem_ctx,
980 int argc,
981 const char **argv)
983 struct policy_handle dom_pol;
984 struct policy_handle user_pol;
985 NTSTATUS status, result;
986 uint32_t access_desired = 0x000f000f;
987 struct dom_sid sid;
988 struct lsa_PrivilegeSet *privs = NULL;
989 int i;
990 struct dcerpc_binding_handle *b = cli->binding_handle;
991 union lsa_revision_info out_revision_info = {
992 .info1 = {
993 .revision = 0,
996 uint32_t out_version = 0;
998 if (argc != 2 ) {
999 printf("Usage: %s SID\n", argv[0]);
1000 return NT_STATUS_OK;
1003 status = name_to_sid(cli, mem_ctx, &sid, argv[1]);
1004 if (!NT_STATUS_IS_OK(status))
1005 goto done;
1007 status = dcerpc_lsa_open_policy_fallback(b,
1008 mem_ctx,
1009 cli->srv_name_slash,
1010 true,
1011 SEC_FLAG_MAXIMUM_ALLOWED,
1012 &out_version,
1013 &out_revision_info,
1014 &dom_pol,
1015 &result);
1016 if (any_nt_status_not_ok(status, result, &status)) {
1017 goto done;
1020 status = dcerpc_lsa_OpenAccount(b, mem_ctx,
1021 &dom_pol,
1022 &sid,
1023 access_desired,
1024 &user_pol,
1025 &result);
1026 if (!NT_STATUS_IS_OK(status))
1027 goto done;
1028 if (!NT_STATUS_IS_OK(result)) {
1029 status = result;
1030 goto done;
1033 status = dcerpc_lsa_EnumPrivsAccount(b, mem_ctx,
1034 &user_pol,
1035 &privs,
1036 &result);
1037 if (!NT_STATUS_IS_OK(status))
1038 goto done;
1039 if (!NT_STATUS_IS_OK(result)) {
1040 status = result;
1041 goto done;
1044 /* Print results */
1045 printf("found %d privileges for SID %s\n\n", privs->count, argv[1]);
1046 printf("high\tlow\tattribute\n");
1048 for (i = 0; i < privs->count; i++) {
1049 printf("%u\t%u\t%u\n",
1050 privs->set[i].luid.high,
1051 privs->set[i].luid.low,
1052 privs->set[i].attribute);
1055 dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result);
1056 done:
1057 return status;
1061 /* Enumerate the privileges of an SID via LsaEnumerateAccountRights */
1063 static NTSTATUS cmd_lsa_enum_acct_rights(struct rpc_pipe_client *cli,
1064 TALLOC_CTX *mem_ctx,
1065 int argc,
1066 const char **argv)
1068 struct policy_handle dom_pol;
1069 NTSTATUS status, result;
1070 struct dom_sid sid;
1071 struct dom_sid_buf buf;
1072 struct lsa_RightSet rights;
1073 struct dcerpc_binding_handle *b = cli->binding_handle;
1074 union lsa_revision_info out_revision_info = {
1075 .info1 = {
1076 .revision = 0,
1079 uint32_t out_version = 0;
1081 int i;
1083 if (argc != 2 ) {
1084 printf("Usage: %s SID\n", argv[0]);
1085 return NT_STATUS_OK;
1088 status = name_to_sid(cli, mem_ctx, &sid, argv[1]);
1089 if (!NT_STATUS_IS_OK(status))
1090 goto done;
1092 status = dcerpc_lsa_open_policy_fallback(b,
1093 mem_ctx,
1094 cli->srv_name_slash,
1095 true,
1096 SEC_FLAG_MAXIMUM_ALLOWED,
1097 &out_version,
1098 &out_revision_info,
1099 &dom_pol,
1100 &result);
1101 if (any_nt_status_not_ok(status, result, &status)) {
1102 goto done;
1105 status = dcerpc_lsa_EnumAccountRights(b, mem_ctx,
1106 &dom_pol,
1107 &sid,
1108 &rights,
1109 &result);
1110 if (!NT_STATUS_IS_OK(status))
1111 goto done;
1112 if (!NT_STATUS_IS_OK(result)) {
1113 status = result;
1114 goto done;
1117 printf("found %d privileges for SID %s\n", rights.count,
1118 dom_sid_str_buf(&sid, &buf));
1120 for (i = 0; i < rights.count; i++) {
1121 printf("\t%s\n", rights.names[i].string);
1124 dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result);
1125 done:
1126 return status;
1130 /* add some privileges to a SID via LsaAddAccountRights */
1132 static NTSTATUS cmd_lsa_add_acct_rights(struct rpc_pipe_client *cli,
1133 TALLOC_CTX *mem_ctx,
1134 int argc,
1135 const char **argv)
1137 struct policy_handle dom_pol;
1138 NTSTATUS status, result;
1139 struct lsa_RightSet rights;
1140 struct dom_sid sid;
1141 int i;
1142 struct dcerpc_binding_handle *b = cli->binding_handle;
1143 union lsa_revision_info out_revision_info = {
1144 .info1 = {
1145 .revision = 0,
1148 uint32_t out_version = 0;
1150 if (argc < 3 ) {
1151 printf("Usage: %s SID [rights...]\n", argv[0]);
1152 return NT_STATUS_OK;
1155 status = name_to_sid(cli, mem_ctx, &sid, argv[1]);
1156 if (!NT_STATUS_IS_OK(status))
1157 goto done;
1159 status = dcerpc_lsa_open_policy_fallback(b,
1160 mem_ctx,
1161 cli->srv_name_slash,
1162 true,
1163 SEC_FLAG_MAXIMUM_ALLOWED,
1164 &out_version,
1165 &out_revision_info,
1166 &dom_pol,
1167 &result);
1168 if (any_nt_status_not_ok(status, result, &status)) {
1169 goto done;
1172 rights.count = argc-2;
1173 rights.names = talloc_array(mem_ctx, struct lsa_StringLarge,
1174 rights.count);
1175 if (!rights.names) {
1176 return NT_STATUS_NO_MEMORY;
1179 for (i=0; i<argc-2; i++) {
1180 init_lsa_StringLarge(&rights.names[i], argv[i+2]);
1183 status = dcerpc_lsa_AddAccountRights(b, mem_ctx,
1184 &dom_pol,
1185 &sid,
1186 &rights,
1187 &result);
1188 if (!NT_STATUS_IS_OK(status))
1189 goto done;
1190 if (!NT_STATUS_IS_OK(result)) {
1191 status = result;
1192 goto done;
1195 dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result);
1196 done:
1197 return status;
1201 /* remove some privileges to a SID via LsaRemoveAccountRights */
1203 static NTSTATUS cmd_lsa_remove_acct_rights(struct rpc_pipe_client *cli,
1204 TALLOC_CTX *mem_ctx,
1205 int argc,
1206 const char **argv)
1208 struct policy_handle dom_pol;
1209 NTSTATUS status, result;
1210 struct lsa_RightSet rights;
1211 struct dom_sid sid;
1212 int i;
1213 struct dcerpc_binding_handle *b = cli->binding_handle;
1214 union lsa_revision_info out_revision_info = {
1215 .info1 = {
1216 .revision = 0,
1219 uint32_t out_version = 0;
1221 if (argc < 3 ) {
1222 printf("Usage: %s SID [rights...]\n", argv[0]);
1223 return NT_STATUS_OK;
1226 status = name_to_sid(cli, mem_ctx, &sid, argv[1]);
1227 if (!NT_STATUS_IS_OK(status))
1228 goto done;
1230 status = dcerpc_lsa_open_policy_fallback(b,
1231 mem_ctx,
1232 cli->srv_name_slash,
1233 true,
1234 SEC_FLAG_MAXIMUM_ALLOWED,
1235 &out_version,
1236 &out_revision_info,
1237 &dom_pol,
1238 &result);
1239 if (any_nt_status_not_ok(status, result, &status)) {
1240 goto done;
1243 rights.count = argc-2;
1244 rights.names = talloc_array(mem_ctx, struct lsa_StringLarge,
1245 rights.count);
1246 if (!rights.names) {
1247 return NT_STATUS_NO_MEMORY;
1250 for (i=0; i<argc-2; i++) {
1251 init_lsa_StringLarge(&rights.names[i], argv[i+2]);
1254 status = dcerpc_lsa_RemoveAccountRights(b, mem_ctx,
1255 &dom_pol,
1256 &sid,
1257 false,
1258 &rights,
1259 &result);
1260 if (!NT_STATUS_IS_OK(status))
1261 goto done;
1262 if (!NT_STATUS_IS_OK(result)) {
1263 status = result;
1264 goto done;
1267 dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result);
1269 done:
1270 return status;
1274 /* Get a privilege value given its name */
1276 static NTSTATUS cmd_lsa_lookup_priv_value(struct rpc_pipe_client *cli,
1277 TALLOC_CTX *mem_ctx,
1278 int argc,
1279 const char **argv)
1281 struct policy_handle pol;
1282 NTSTATUS status, result;
1283 struct lsa_LUID luid;
1284 struct lsa_String name;
1285 struct dcerpc_binding_handle *b = cli->binding_handle;
1286 union lsa_revision_info out_revision_info = {
1287 .info1 = {
1288 .revision = 0,
1291 uint32_t out_version = 0;
1293 if (argc != 2 ) {
1294 printf("Usage: %s name\n", argv[0]);
1295 return NT_STATUS_OK;
1298 status = dcerpc_lsa_open_policy_fallback(b,
1299 mem_ctx,
1300 cli->srv_name_slash,
1301 true,
1302 SEC_FLAG_MAXIMUM_ALLOWED,
1303 &out_version,
1304 &out_revision_info,
1305 &pol,
1306 &result);
1307 if (any_nt_status_not_ok(status, result, &status)) {
1308 goto done;
1311 init_lsa_String(&name, argv[1]);
1313 status = dcerpc_lsa_LookupPrivValue(b, mem_ctx,
1314 &pol,
1315 &name,
1316 &luid,
1317 &result);
1318 if (!NT_STATUS_IS_OK(status))
1319 goto done;
1320 if (!NT_STATUS_IS_OK(result)) {
1321 status = result;
1322 goto done;
1325 /* Print results */
1327 printf("%u:%u (0x%x:0x%x)\n", luid.high, luid.low, luid.high, luid.low);
1329 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
1330 done:
1331 return status;
1334 /* Query LSA security object */
1336 static NTSTATUS cmd_lsa_query_secobj(struct rpc_pipe_client *cli,
1337 TALLOC_CTX *mem_ctx,
1338 int argc,
1339 const char **argv)
1341 struct policy_handle pol;
1342 NTSTATUS status, result;
1343 struct sec_desc_buf *sdb;
1344 uint32_t sec_info = SECINFO_DACL;
1345 struct dcerpc_binding_handle *b = cli->binding_handle;
1346 union lsa_revision_info out_revision_info = {
1347 .info1 = {
1348 .revision = 0,
1351 uint32_t out_version = 0;
1353 if (argc < 1 || argc > 2) {
1354 printf("Usage: %s [sec_info]\n", argv[0]);
1355 return NT_STATUS_OK;
1358 if (argc == 2)
1359 sscanf(argv[1], "%x", &sec_info);
1361 status = dcerpc_lsa_open_policy_fallback(b,
1362 mem_ctx,
1363 cli->srv_name_slash,
1364 true,
1365 SEC_FLAG_MAXIMUM_ALLOWED,
1366 &out_version,
1367 &out_revision_info,
1368 &pol,
1369 &result);
1370 if (any_nt_status_not_ok(status, result, &status)) {
1371 goto done;
1374 status = dcerpc_lsa_QuerySecurity(b, mem_ctx,
1375 &pol,
1376 sec_info,
1377 &sdb,
1378 &result);
1379 if (!NT_STATUS_IS_OK(status))
1380 goto done;
1381 if (!NT_STATUS_IS_OK(result)) {
1382 status = result;
1383 goto done;
1386 /* Print results */
1388 display_sec_desc(sdb->sd);
1390 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
1391 done:
1392 return status;
1395 static void display_trust_dom_info_4(struct lsa_TrustDomainInfoPassword *p,
1396 DATA_BLOB session_key)
1398 char *pwd, *pwd_old;
1400 DATA_BLOB data = data_blob_const(p->password->data, p->password->length);
1401 DATA_BLOB data_old = data_blob_const(p->old_password->data, p->old_password->length);
1403 pwd = sess_decrypt_string(talloc_tos(), &data, &session_key);
1404 pwd_old = sess_decrypt_string(talloc_tos(), &data_old, &session_key);
1406 d_printf("Password:\t%s\n", pwd);
1407 d_printf("Old Password:\t%s\n", pwd_old);
1409 talloc_free(pwd);
1410 talloc_free(pwd_old);
1413 static void display_trust_dom_info(TALLOC_CTX *mem_ctx,
1414 union lsa_TrustedDomainInfo *info,
1415 enum lsa_TrustDomInfoEnum info_class,
1416 DATA_BLOB session_key)
1418 switch (info_class) {
1419 case LSA_TRUSTED_DOMAIN_INFO_PASSWORD:
1420 display_trust_dom_info_4(&info->password, session_key);
1421 break;
1422 default: {
1423 const char *str = NULL;
1424 str = NDR_PRINT_UNION_STRING(mem_ctx,
1425 lsa_TrustedDomainInfo,
1426 info_class, info);
1427 if (str) {
1428 d_printf("%s\n", str);
1430 break;
1435 static NTSTATUS cmd_lsa_query_trustdominfobysid(struct rpc_pipe_client *cli,
1436 TALLOC_CTX *mem_ctx,
1437 int argc,
1438 const char **argv)
1440 struct policy_handle pol;
1441 NTSTATUS status, result;
1442 struct dom_sid dom_sid;
1443 uint32_t access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
1444 union lsa_TrustedDomainInfo *info = NULL;
1445 enum lsa_TrustDomInfoEnum info_class = 1;
1446 DATA_BLOB session_key;
1447 struct dcerpc_binding_handle *b = cli->binding_handle;
1448 union lsa_revision_info out_revision_info = {
1449 .info1 = {
1450 .revision = 0,
1453 uint32_t out_version = 0;
1455 if (argc > 3 || argc < 2) {
1456 printf("Usage: %s [sid] [info_class]\n", argv[0]);
1457 return NT_STATUS_OK;
1460 if (!string_to_sid(&dom_sid, argv[1]))
1461 return NT_STATUS_NO_MEMORY;
1463 if (argc == 3)
1464 info_class = atoi(argv[2]);
1466 status = dcerpc_lsa_open_policy_fallback(b,
1467 mem_ctx,
1468 cli->srv_name_slash,
1469 true,
1470 access_mask,
1471 &out_version,
1472 &out_revision_info,
1473 &pol,
1474 &result);
1475 if (any_nt_status_not_ok(status, result, &status)) {
1476 goto done;
1479 status = dcerpc_lsa_QueryTrustedDomainInfoBySid(b, mem_ctx,
1480 &pol,
1481 &dom_sid,
1482 info_class,
1483 &info,
1484 &result);
1485 if (!NT_STATUS_IS_OK(status))
1486 goto done;
1487 if (!NT_STATUS_IS_OK(result)) {
1488 status = result;
1489 goto done;
1492 status = dcerpc_binding_handle_transport_session_key(
1493 b, mem_ctx, &session_key);
1494 if (!NT_STATUS_IS_OK(status)) {
1495 DEBUG(0, ("Could not retrieve session key: %s\n", nt_errstr(status)));
1496 goto done;
1499 display_trust_dom_info(mem_ctx, info, info_class, session_key);
1501 done:
1502 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
1504 return status;
1507 static NTSTATUS cmd_lsa_query_trustdominfobyname(struct rpc_pipe_client *cli,
1508 TALLOC_CTX *mem_ctx,
1509 int argc,
1510 const char **argv)
1512 struct policy_handle pol;
1513 NTSTATUS status, result;
1514 uint32_t access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
1515 union lsa_TrustedDomainInfo *info = NULL;
1516 enum lsa_TrustDomInfoEnum info_class = 1;
1517 struct lsa_String trusted_domain;
1518 struct dcerpc_binding_handle *b = cli->binding_handle;
1519 DATA_BLOB session_key;
1520 union lsa_revision_info out_revision_info = {
1521 .info1 = {
1522 .revision = 0,
1525 uint32_t out_version = 0;
1527 if (argc > 3 || argc < 2) {
1528 printf("Usage: %s [name] [info_class]\n", argv[0]);
1529 return NT_STATUS_OK;
1532 if (argc == 3)
1533 info_class = atoi(argv[2]);
1535 status = dcerpc_lsa_open_policy_fallback(b,
1536 mem_ctx,
1537 cli->srv_name_slash,
1538 true,
1539 access_mask,
1540 &out_version,
1541 &out_revision_info,
1542 &pol,
1543 &result);
1544 if (any_nt_status_not_ok(status, result, &status)) {
1545 goto done;
1548 init_lsa_String(&trusted_domain, argv[1]);
1550 status = dcerpc_lsa_QueryTrustedDomainInfoByName(b, mem_ctx,
1551 &pol,
1552 &trusted_domain,
1553 info_class,
1554 &info,
1555 &result);
1556 if (!NT_STATUS_IS_OK(status))
1557 goto done;
1558 if (!NT_STATUS_IS_OK(result)) {
1559 status = result;
1560 goto done;
1563 status = dcerpc_binding_handle_transport_session_key(
1564 b, mem_ctx, &session_key);
1565 if (!NT_STATUS_IS_OK(status)) {
1566 DEBUG(0, ("Could not retrieve session key: %s\n", nt_errstr(status)));
1567 goto done;
1570 display_trust_dom_info(mem_ctx, info, info_class, session_key);
1572 done:
1573 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
1575 return status;
1578 static NTSTATUS cmd_lsa_set_trustdominfo(struct rpc_pipe_client *cli,
1579 TALLOC_CTX *mem_ctx, int argc,
1580 const char **argv)
1582 struct policy_handle pol, trustdom_pol;
1583 NTSTATUS status, result;
1584 uint32_t access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
1585 union lsa_TrustedDomainInfo info;
1586 struct dom_sid dom_sid;
1587 enum lsa_TrustDomInfoEnum info_class = 1;
1588 struct dcerpc_binding_handle *b = cli->binding_handle;
1589 union lsa_revision_info out_revision_info = {
1590 .info1 = {
1591 .revision = 0,
1594 uint32_t out_version = 0;
1596 if (argc > 4 || argc < 3) {
1597 printf("Usage: %s [sid] [info_class] [value]\n", argv[0]);
1598 return NT_STATUS_OK;
1601 if (!string_to_sid(&dom_sid, argv[1])) {
1602 return NT_STATUS_NO_MEMORY;
1606 info_class = atoi(argv[2]);
1608 switch (info_class) {
1609 case 13: /* LSA_TRUSTED_DOMAIN_SUPPORTED_ENCRYPTION_TYPES */
1610 info.enc_types.enc_types = atoi(argv[3]);
1611 break;
1612 default:
1613 return NT_STATUS_INVALID_PARAMETER;
1616 status = dcerpc_lsa_open_policy_fallback(b,
1617 mem_ctx,
1618 cli->srv_name_slash,
1619 true,
1620 access_mask,
1621 &out_version,
1622 &out_revision_info,
1623 &pol,
1624 &result);
1625 if (any_nt_status_not_ok(status, result, &status)) {
1626 goto done;
1629 status = dcerpc_lsa_OpenTrustedDomain(b, mem_ctx,
1630 &pol,
1631 &dom_sid,
1632 access_mask,
1633 &trustdom_pol,
1634 &result);
1635 if (!NT_STATUS_IS_OK(status)) {
1636 goto done;
1638 if (!NT_STATUS_IS_OK(result)) {
1639 status = result;
1640 goto done;
1643 status = dcerpc_lsa_SetInformationTrustedDomain(b, mem_ctx,
1644 &trustdom_pol,
1645 info_class,
1646 &info,
1647 &result);
1648 if (!NT_STATUS_IS_OK(status)) {
1649 goto done;
1651 if (!NT_STATUS_IS_OK(result)) {
1652 status = result;
1653 goto done;
1655 done:
1656 dcerpc_lsa_Close(b, mem_ctx, &trustdom_pol, &result);
1657 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
1659 return status;
1662 static NTSTATUS cmd_lsa_query_trustdominfo(struct rpc_pipe_client *cli,
1663 TALLOC_CTX *mem_ctx,
1664 int argc,
1665 const char **argv)
1667 struct policy_handle pol, trustdom_pol;
1668 NTSTATUS status, result;
1669 uint32_t access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
1670 union lsa_TrustedDomainInfo *info = NULL;
1671 struct dom_sid dom_sid;
1672 enum lsa_TrustDomInfoEnum info_class = 1;
1673 DATA_BLOB session_key;
1674 struct dcerpc_binding_handle *b = cli->binding_handle;
1675 union lsa_revision_info out_revision_info = {
1676 .info1 = {
1677 .revision = 0,
1680 uint32_t out_version = 0;
1682 if (argc > 3 || argc < 2) {
1683 printf("Usage: %s [sid] [info_class]\n", argv[0]);
1684 return NT_STATUS_OK;
1687 if (!string_to_sid(&dom_sid, argv[1]))
1688 return NT_STATUS_NO_MEMORY;
1691 if (argc == 3)
1692 info_class = atoi(argv[2]);
1694 status = dcerpc_lsa_open_policy_fallback(b,
1695 mem_ctx,
1696 cli->srv_name_slash,
1697 true,
1698 access_mask,
1699 &out_version,
1700 &out_revision_info,
1701 &pol,
1702 &result);
1703 if (any_nt_status_not_ok(status, result, &status)) {
1704 goto done;
1707 status = dcerpc_lsa_OpenTrustedDomain(b, mem_ctx,
1708 &pol,
1709 &dom_sid,
1710 access_mask,
1711 &trustdom_pol,
1712 &result);
1713 if (!NT_STATUS_IS_OK(status))
1714 goto done;
1715 if (!NT_STATUS_IS_OK(result)) {
1716 status = result;
1717 goto done;
1720 status = dcerpc_lsa_QueryTrustedDomainInfo(b, mem_ctx,
1721 &trustdom_pol,
1722 info_class,
1723 &info,
1724 &result);
1725 if (!NT_STATUS_IS_OK(status))
1726 goto done;
1727 if (!NT_STATUS_IS_OK(result)) {
1728 status = result;
1729 goto done;
1732 status = dcerpc_binding_handle_transport_session_key(
1733 b, mem_ctx, &session_key);
1734 if (!NT_STATUS_IS_OK(status)) {
1735 DEBUG(0, ("Could not retrieve session key: %s\n", nt_errstr(status)));
1736 goto done;
1739 display_trust_dom_info(mem_ctx, info, info_class, session_key);
1741 done:
1742 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
1744 return status;
1747 static NTSTATUS cmd_lsa_get_username(struct rpc_pipe_client *cli,
1748 TALLOC_CTX *mem_ctx, int argc,
1749 const char **argv)
1751 NTSTATUS status, result;
1752 const char *servername = cli->desthost;
1753 struct lsa_String *account_name = NULL;
1754 struct lsa_String *authority_name = NULL;
1755 struct dcerpc_binding_handle *b = cli->binding_handle;
1757 if (argc > 2) {
1758 printf("Usage: %s servername\n", argv[0]);
1759 return NT_STATUS_OK;
1762 status = dcerpc_lsa_GetUserName(b, mem_ctx,
1763 servername,
1764 &account_name,
1765 &authority_name,
1766 &result);
1767 if (!NT_STATUS_IS_OK(status)) {
1768 goto done;
1770 if (!NT_STATUS_IS_OK(result)) {
1771 status = result;
1772 goto done;
1775 /* Print results */
1777 printf("Account Name: %s, Authority Name: %s\n",
1778 account_name->string, authority_name ? authority_name->string :
1779 "");
1781 done:
1782 return status;
1785 static NTSTATUS cmd_lsa_add_priv(struct rpc_pipe_client *cli,
1786 TALLOC_CTX *mem_ctx, int argc,
1787 const char **argv)
1789 struct policy_handle dom_pol, user_pol;
1790 NTSTATUS status, result;
1791 struct lsa_PrivilegeSet privs;
1792 struct lsa_LUIDAttribute *set = NULL;
1793 struct dom_sid sid;
1794 int i;
1795 struct dcerpc_binding_handle *b = cli->binding_handle;
1796 union lsa_revision_info out_revision_info = {
1797 .info1 = {
1798 .revision = 0,
1801 uint32_t out_version = 0;
1803 ZERO_STRUCT(privs);
1805 if (argc < 3 ) {
1806 printf("Usage: %s SID [rights...]\n", argv[0]);
1807 return NT_STATUS_OK;
1810 status = name_to_sid(cli, mem_ctx, &sid, argv[1]);
1811 if (!NT_STATUS_IS_OK(status)) {
1812 goto done;
1815 status = dcerpc_lsa_open_policy_fallback(b,
1816 mem_ctx,
1817 cli->srv_name_slash,
1818 true,
1819 SEC_FLAG_MAXIMUM_ALLOWED,
1820 &out_version,
1821 &out_revision_info,
1822 &dom_pol,
1823 &result);
1824 if (any_nt_status_not_ok(status, result, &status)) {
1825 goto done;
1828 status = dcerpc_lsa_OpenAccount(b, mem_ctx,
1829 &dom_pol,
1830 &sid,
1831 SEC_FLAG_MAXIMUM_ALLOWED,
1832 &user_pol,
1833 &result);
1834 if (!NT_STATUS_IS_OK(status)) {
1835 goto done;
1837 if (!NT_STATUS_IS_OK(result)) {
1838 status = result;
1839 goto done;
1842 for (i=2; i<argc; i++) {
1844 struct lsa_String priv_name;
1845 struct lsa_LUID luid;
1847 init_lsa_String(&priv_name, argv[i]);
1849 status = dcerpc_lsa_LookupPrivValue(b, mem_ctx,
1850 &dom_pol,
1851 &priv_name,
1852 &luid,
1853 &result);
1854 if (!NT_STATUS_IS_OK(status)) {
1855 continue;
1857 if (!NT_STATUS_IS_OK(result)) {
1858 status = result;
1859 continue;
1862 privs.count++;
1863 set = talloc_realloc(mem_ctx, set,
1864 struct lsa_LUIDAttribute,
1865 privs.count);
1866 if (!set) {
1867 return NT_STATUS_NO_MEMORY;
1870 set[privs.count-1].luid = luid;
1871 set[privs.count-1].attribute = 0;
1874 privs.set = set;
1876 status = dcerpc_lsa_AddPrivilegesToAccount(b, mem_ctx,
1877 &user_pol,
1878 &privs,
1879 &result);
1880 if (!NT_STATUS_IS_OK(status)) {
1881 goto done;
1883 if (!NT_STATUS_IS_OK(result)) {
1884 status = result;
1885 goto done;
1888 dcerpc_lsa_Close(b, mem_ctx, &user_pol, &result);
1889 dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result);
1890 done:
1891 return status;
1894 static NTSTATUS cmd_lsa_del_priv(struct rpc_pipe_client *cli,
1895 TALLOC_CTX *mem_ctx, int argc,
1896 const char **argv)
1898 struct policy_handle dom_pol, user_pol;
1899 NTSTATUS status, result;
1900 struct lsa_PrivilegeSet privs;
1901 struct lsa_LUIDAttribute *set = NULL;
1902 struct dom_sid sid;
1903 int i;
1904 struct dcerpc_binding_handle *b = cli->binding_handle;
1905 union lsa_revision_info out_revision_info = {
1906 .info1 = {
1907 .revision = 0,
1910 uint32_t out_version = 0;
1912 ZERO_STRUCT(privs);
1914 if (argc < 3 ) {
1915 printf("Usage: %s SID [rights...]\n", argv[0]);
1916 return NT_STATUS_OK;
1919 status = name_to_sid(cli, mem_ctx, &sid, argv[1]);
1920 if (!NT_STATUS_IS_OK(status)) {
1921 goto done;
1924 status = dcerpc_lsa_open_policy_fallback(b,
1925 mem_ctx,
1926 cli->srv_name_slash,
1927 true,
1928 SEC_FLAG_MAXIMUM_ALLOWED,
1929 &out_version,
1930 &out_revision_info,
1931 &dom_pol,
1932 &result);
1933 if (any_nt_status_not_ok(status, result, &status)) {
1934 goto done;
1937 status = dcerpc_lsa_OpenAccount(b, mem_ctx,
1938 &dom_pol,
1939 &sid,
1940 SEC_FLAG_MAXIMUM_ALLOWED,
1941 &user_pol,
1942 &result);
1943 if (!NT_STATUS_IS_OK(status)) {
1944 goto done;
1946 if (!NT_STATUS_IS_OK(result)) {
1947 status = result;
1948 goto done;
1951 for (i=2; i<argc; i++) {
1953 struct lsa_String priv_name;
1954 struct lsa_LUID luid;
1956 init_lsa_String(&priv_name, argv[i]);
1958 status = dcerpc_lsa_LookupPrivValue(b, mem_ctx,
1959 &dom_pol,
1960 &priv_name,
1961 &luid,
1962 &result);
1963 if (!NT_STATUS_IS_OK(status)) {
1964 continue;
1966 if (!NT_STATUS_IS_OK(result)) {
1967 status = result;
1968 continue;
1971 privs.count++;
1972 set = talloc_realloc(mem_ctx, set,
1973 struct lsa_LUIDAttribute,
1974 privs.count);
1975 if (!set) {
1976 return NT_STATUS_NO_MEMORY;
1979 set[privs.count-1].luid = luid;
1980 set[privs.count-1].attribute = 0;
1983 privs.set = set;
1986 status = dcerpc_lsa_RemovePrivilegesFromAccount(b, mem_ctx,
1987 &user_pol,
1988 false,
1989 &privs,
1990 &result);
1991 if (!NT_STATUS_IS_OK(status)) {
1992 goto done;
1994 if (!NT_STATUS_IS_OK(result)) {
1995 status = result;
1996 goto done;
1999 dcerpc_lsa_Close(b, mem_ctx, &user_pol, &result);
2000 dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result);
2001 done:
2002 return status;
2005 static NTSTATUS cmd_lsa_create_secret(struct rpc_pipe_client *cli,
2006 TALLOC_CTX *mem_ctx, int argc,
2007 const char **argv)
2009 NTSTATUS status, result;
2010 struct policy_handle handle, sec_handle;
2011 struct lsa_String name;
2012 struct dcerpc_binding_handle *b = cli->binding_handle;
2013 union lsa_revision_info out_revision_info = {
2014 .info1 = {
2015 .revision = 0,
2018 uint32_t out_version = 0;
2020 if (argc < 2) {
2021 printf("Usage: %s name\n", argv[0]);
2022 return NT_STATUS_OK;
2025 status = dcerpc_lsa_open_policy_fallback(b,
2026 mem_ctx,
2027 cli->srv_name_slash,
2028 true,
2029 SEC_FLAG_MAXIMUM_ALLOWED,
2030 &out_version,
2031 &out_revision_info,
2032 &sec_handle,
2033 &result);
2034 if (any_nt_status_not_ok(status, result, &status)) {
2035 return status;
2038 init_lsa_String(&name, argv[1]);
2040 status = dcerpc_lsa_CreateSecret(b, mem_ctx,
2041 &handle,
2042 name,
2043 SEC_FLAG_MAXIMUM_ALLOWED,
2044 &sec_handle,
2045 &result);
2046 if (!NT_STATUS_IS_OK(status)) {
2047 goto done;
2049 if (!NT_STATUS_IS_OK(result)) {
2050 status = result;
2051 goto done;
2054 done:
2055 if (is_valid_policy_hnd(&sec_handle)) {
2056 dcerpc_lsa_Close(b, mem_ctx, &sec_handle, &result);
2058 if (is_valid_policy_hnd(&handle)) {
2059 dcerpc_lsa_Close(b, mem_ctx, &handle, &result);
2062 return status;
2065 static NTSTATUS cmd_lsa_delete_secret(struct rpc_pipe_client *cli,
2066 TALLOC_CTX *mem_ctx, int argc,
2067 const char **argv)
2069 NTSTATUS status, result;
2070 struct policy_handle handle, sec_handle;
2071 struct lsa_String name;
2072 struct dcerpc_binding_handle *b = cli->binding_handle;
2073 union lsa_revision_info out_revision_info = {
2074 .info1 = {
2075 .revision = 0,
2078 uint32_t out_version = 0;
2080 if (argc < 2) {
2081 printf("Usage: %s name\n", argv[0]);
2082 return NT_STATUS_OK;
2085 status = dcerpc_lsa_open_policy_fallback(b,
2086 mem_ctx,
2087 cli->srv_name_slash,
2088 true,
2089 SEC_FLAG_MAXIMUM_ALLOWED,
2090 &out_version,
2091 &out_revision_info,
2092 &handle,
2093 &result);
2094 if (any_nt_status_not_ok(status, result, &status)) {
2095 return status;
2098 init_lsa_String(&name, argv[1]);
2100 status = dcerpc_lsa_OpenSecret(b, mem_ctx,
2101 &handle,
2102 name,
2103 SEC_FLAG_MAXIMUM_ALLOWED,
2104 &sec_handle,
2105 &result);
2106 if (!NT_STATUS_IS_OK(status)) {
2107 goto done;
2109 if (!NT_STATUS_IS_OK(result)) {
2110 status = result;
2111 goto done;
2114 status = dcerpc_lsa_DeleteObject(b, mem_ctx,
2115 &sec_handle,
2116 &result);
2117 if (!NT_STATUS_IS_OK(status)) {
2118 goto done;
2120 if (!NT_STATUS_IS_OK(result)) {
2121 status = result;
2122 goto done;
2125 done:
2126 if (is_valid_policy_hnd(&sec_handle)) {
2127 dcerpc_lsa_Close(b, mem_ctx, &sec_handle, &result);
2129 if (is_valid_policy_hnd(&handle)) {
2130 dcerpc_lsa_Close(b, mem_ctx, &handle, &result);
2133 return status;
2136 static NTSTATUS cmd_lsa_query_secret(struct rpc_pipe_client *cli,
2137 TALLOC_CTX *mem_ctx, int argc,
2138 const char **argv)
2140 NTSTATUS status, result;
2141 struct policy_handle handle, sec_handle;
2142 struct lsa_String name;
2143 struct lsa_DATA_BUF_PTR new_val;
2144 NTTIME new_mtime = 0;
2145 struct lsa_DATA_BUF_PTR old_val;
2146 NTTIME old_mtime = 0;
2147 DATA_BLOB session_key;
2148 DATA_BLOB new_blob = data_blob_null;
2149 DATA_BLOB old_blob = data_blob_null;
2150 char *new_secret, *old_secret;
2151 struct dcerpc_binding_handle *b = cli->binding_handle;
2152 union lsa_revision_info out_revision_info = {
2153 .info1 = {
2154 .revision = 0,
2157 uint32_t out_version = 0;
2159 if (argc < 2) {
2160 printf("Usage: %s name\n", argv[0]);
2161 return NT_STATUS_OK;
2164 status = dcerpc_lsa_open_policy_fallback(b,
2165 mem_ctx,
2166 cli->srv_name_slash,
2167 true,
2168 SEC_FLAG_MAXIMUM_ALLOWED,
2169 &out_version,
2170 &out_revision_info,
2171 &handle,
2172 &result);
2173 if (any_nt_status_not_ok(status, result, &status)) {
2174 return status;
2177 init_lsa_String(&name, argv[1]);
2179 status = dcerpc_lsa_OpenSecret(b, mem_ctx,
2180 &handle,
2181 name,
2182 SEC_FLAG_MAXIMUM_ALLOWED,
2183 &sec_handle,
2184 &result);
2185 if (!NT_STATUS_IS_OK(status)) {
2186 goto done;
2188 if (!NT_STATUS_IS_OK(result)) {
2189 status = result;
2190 goto done;
2193 ZERO_STRUCT(new_val);
2194 ZERO_STRUCT(old_val);
2196 status = dcerpc_lsa_QuerySecret(b, mem_ctx,
2197 &sec_handle,
2198 &new_val,
2199 &new_mtime,
2200 &old_val,
2201 &old_mtime,
2202 &result);
2203 if (!NT_STATUS_IS_OK(status)) {
2204 goto done;
2206 if (!NT_STATUS_IS_OK(result)) {
2207 status = result;
2208 goto done;
2211 status = dcerpc_binding_handle_transport_session_key(
2212 b, mem_ctx, &session_key);
2213 if (!NT_STATUS_IS_OK(status)) {
2214 goto done;
2217 if (new_val.buf) {
2218 new_blob = data_blob_const(new_val.buf->data, new_val.buf->length);
2220 if (old_val.buf) {
2221 old_blob = data_blob_const(old_val.buf->data, old_val.buf->length);
2224 new_secret = sess_decrypt_string(mem_ctx, &new_blob, &session_key);
2225 old_secret = sess_decrypt_string(mem_ctx, &old_blob, &session_key);
2226 if (new_secret) {
2227 d_printf("new secret: %s\n", new_secret);
2229 if (old_secret) {
2230 d_printf("old secret: %s\n", old_secret);
2233 done:
2234 if (is_valid_policy_hnd(&sec_handle)) {
2235 dcerpc_lsa_Close(b, mem_ctx, &sec_handle, &result);
2237 if (is_valid_policy_hnd(&handle)) {
2238 dcerpc_lsa_Close(b, mem_ctx, &handle, &result);
2241 return status;
2244 static NTSTATUS cmd_lsa_set_secret(struct rpc_pipe_client *cli,
2245 TALLOC_CTX *mem_ctx, int argc,
2246 const char **argv)
2248 NTSTATUS status, result;
2249 struct policy_handle handle, sec_handle;
2250 struct lsa_String name;
2251 struct lsa_DATA_BUF new_val;
2252 struct lsa_DATA_BUF old_val;
2253 DATA_BLOB enc_key;
2254 DATA_BLOB session_key;
2255 struct dcerpc_binding_handle *b = cli->binding_handle;
2256 union lsa_revision_info out_revision_info = {
2257 .info1 = {
2258 .revision = 0,
2261 uint32_t out_version = 0;
2263 if (argc < 3) {
2264 printf("Usage: %s name secret\n", argv[0]);
2265 return NT_STATUS_OK;
2268 status = dcerpc_lsa_open_policy_fallback(b,
2269 mem_ctx,
2270 cli->srv_name_slash,
2271 true,
2272 SEC_FLAG_MAXIMUM_ALLOWED,
2273 &out_version,
2274 &out_revision_info,
2275 &handle,
2276 &result);
2277 if (any_nt_status_not_ok(status, result, &status)) {
2278 return status;
2281 init_lsa_String(&name, argv[1]);
2283 status = dcerpc_lsa_OpenSecret(b, mem_ctx,
2284 &handle,
2285 name,
2286 SEC_FLAG_MAXIMUM_ALLOWED,
2287 &sec_handle,
2288 &result);
2289 if (!NT_STATUS_IS_OK(status)) {
2290 goto done;
2292 if (!NT_STATUS_IS_OK(result)) {
2293 status = result;
2294 goto done;
2297 ZERO_STRUCT(new_val);
2298 ZERO_STRUCT(old_val);
2300 status = dcerpc_binding_handle_transport_session_key(
2301 b, mem_ctx, &session_key);
2302 if (!NT_STATUS_IS_OK(status)) {
2303 goto done;
2306 enc_key = sess_encrypt_string(argv[2], &session_key);
2308 new_val.length = enc_key.length;
2309 new_val.size = enc_key.length;
2310 new_val.data = enc_key.data;
2312 status = dcerpc_lsa_SetSecret(b, mem_ctx,
2313 &sec_handle,
2314 &new_val,
2315 NULL,
2316 &result);
2317 if (!NT_STATUS_IS_OK(status)) {
2318 goto done;
2320 if (!NT_STATUS_IS_OK(result)) {
2321 status = result;
2322 goto done;
2325 done:
2326 if (is_valid_policy_hnd(&sec_handle)) {
2327 dcerpc_lsa_Close(b, mem_ctx, &sec_handle, &result);
2329 if (is_valid_policy_hnd(&handle)) {
2330 dcerpc_lsa_Close(b, mem_ctx, &handle, &result);
2333 return status;
2336 static NTSTATUS cmd_lsa_retrieve_private_data(struct rpc_pipe_client *cli,
2337 TALLOC_CTX *mem_ctx, int argc,
2338 const char **argv)
2340 NTSTATUS status, result;
2341 struct policy_handle handle;
2342 struct lsa_String name;
2343 struct lsa_DATA_BUF *val;
2344 DATA_BLOB session_key;
2345 DATA_BLOB blob = data_blob_null;
2346 char *secret;
2347 struct dcerpc_binding_handle *b = cli->binding_handle;
2348 union lsa_revision_info out_revision_info = {
2349 .info1 = {
2350 .revision = 0,
2353 uint32_t out_version = 0;
2355 if (argc < 2) {
2356 printf("Usage: %s name\n", argv[0]);
2357 return NT_STATUS_OK;
2360 status = dcerpc_lsa_open_policy_fallback(b,
2361 mem_ctx,
2362 cli->srv_name_slash,
2363 true,
2364 SEC_FLAG_MAXIMUM_ALLOWED,
2365 &out_version,
2366 &out_revision_info,
2367 &handle,
2368 &result);
2369 if (any_nt_status_not_ok(status, result, &status)) {
2370 return status;
2373 init_lsa_String(&name, argv[1]);
2375 ZERO_STRUCT(val);
2377 status = dcerpc_lsa_RetrievePrivateData(b, mem_ctx,
2378 &handle,
2379 &name,
2380 &val,
2381 &result);
2382 if (!NT_STATUS_IS_OK(status)) {
2383 goto done;
2385 if (!NT_STATUS_IS_OK(result)) {
2386 status = result;
2387 goto done;
2390 status = dcerpc_binding_handle_transport_session_key(
2391 b, mem_ctx, &session_key);
2392 if (!NT_STATUS_IS_OK(status)) {
2393 goto done;
2396 if (val) {
2397 blob = data_blob_const(val->data, val->length);
2400 secret = sess_decrypt_string(mem_ctx, &blob, &session_key);
2401 if (secret) {
2402 d_printf("secret: %s\n", secret);
2405 done:
2406 if (is_valid_policy_hnd(&handle)) {
2407 dcerpc_lsa_Close(b, mem_ctx, &handle, &result);
2410 return status;
2413 static NTSTATUS cmd_lsa_store_private_data(struct rpc_pipe_client *cli,
2414 TALLOC_CTX *mem_ctx, int argc,
2415 const char **argv)
2417 NTSTATUS status, result;
2418 struct policy_handle handle;
2419 struct lsa_String name;
2420 struct lsa_DATA_BUF val;
2421 DATA_BLOB session_key;
2422 DATA_BLOB enc_key;
2423 struct dcerpc_binding_handle *b = cli->binding_handle;
2424 union lsa_revision_info out_revision_info = {
2425 .info1 = {
2426 .revision = 0,
2429 uint32_t out_version = 0;
2431 if (argc < 3) {
2432 printf("Usage: %s name secret\n", argv[0]);
2433 return NT_STATUS_OK;
2436 status = dcerpc_lsa_open_policy_fallback(b,
2437 mem_ctx,
2438 cli->srv_name_slash,
2439 true,
2440 SEC_FLAG_MAXIMUM_ALLOWED,
2441 &out_version,
2442 &out_revision_info,
2443 &handle,
2444 &result);
2445 if (any_nt_status_not_ok(status, result, &status)) {
2446 return status;
2449 init_lsa_String(&name, argv[1]);
2451 ZERO_STRUCT(val);
2453 status = dcerpc_binding_handle_transport_session_key(
2454 b, mem_ctx, &session_key);
2455 if (!NT_STATUS_IS_OK(status)) {
2456 goto done;
2459 enc_key = sess_encrypt_string(argv[2], &session_key);
2461 val.length = enc_key.length;
2462 val.size = enc_key.length;
2463 val.data = enc_key.data;
2465 status = dcerpc_lsa_StorePrivateData(b, mem_ctx,
2466 &handle,
2467 &name,
2468 &val,
2469 &result);
2470 if (!NT_STATUS_IS_OK(status)) {
2471 goto done;
2473 if (!NT_STATUS_IS_OK(result)) {
2474 status = result;
2475 goto done;
2478 done:
2479 if (is_valid_policy_hnd(&handle)) {
2480 dcerpc_lsa_Close(b, mem_ctx, &handle, &result);
2483 return status;
2486 static NTSTATUS cmd_lsa_create_trusted_domain(struct rpc_pipe_client *cli,
2487 TALLOC_CTX *mem_ctx, int argc,
2488 const char **argv)
2490 NTSTATUS status, result;
2491 struct policy_handle handle, trustdom_handle;
2492 struct dom_sid sid;
2493 struct lsa_DomainInfo info;
2494 struct dcerpc_binding_handle *b = cli->binding_handle;
2495 union lsa_revision_info out_revision_info = {
2496 .info1 = {
2497 .revision = 0,
2500 uint32_t out_version = 0;
2502 if (argc < 3) {
2503 printf("Usage: %s name sid\n", argv[0]);
2504 return NT_STATUS_OK;
2507 status = dcerpc_lsa_open_policy_fallback(b,
2508 mem_ctx,
2509 cli->srv_name_slash,
2510 true,
2511 SEC_FLAG_MAXIMUM_ALLOWED,
2512 &out_version,
2513 &out_revision_info,
2514 &handle,
2515 &result);
2516 if (any_nt_status_not_ok(status, result, &status)) {
2517 return status;
2520 init_lsa_StringLarge(&info.name, argv[1]);
2521 info.sid = &sid;
2522 string_to_sid(&sid, argv[2]);
2524 status = dcerpc_lsa_CreateTrustedDomain(b, mem_ctx,
2525 &handle,
2526 &info,
2527 SEC_FLAG_MAXIMUM_ALLOWED,
2528 &trustdom_handle,
2529 &result);
2530 if (!NT_STATUS_IS_OK(status)) {
2531 goto done;
2533 if (!NT_STATUS_IS_OK(result)) {
2534 status = result;
2535 goto done;
2538 done:
2539 if (is_valid_policy_hnd(&trustdom_handle)) {
2540 dcerpc_lsa_Close(b, mem_ctx, &trustdom_handle, &result);
2543 if (is_valid_policy_hnd(&handle)) {
2544 dcerpc_lsa_Close(b, mem_ctx, &handle, &result);
2547 return status;
2550 static NTSTATUS cmd_lsa_create_trusted_domain_ex3(struct rpc_pipe_client *cli,
2551 TALLOC_CTX *mem_ctx,
2552 int argc,
2553 const char **argv)
2555 struct dcerpc_binding_handle *b = cli->binding_handle;
2556 struct policy_handle handle = {
2557 .handle_type = 0,
2559 struct policy_handle trustdom_handle = {
2560 .handle_type = 0,
2562 struct dom_sid sid = {
2563 .num_auths = 0,
2565 union lsa_revision_info out_revision_info = {
2566 .info1 = {
2567 .revision = 0,
2570 struct lsa_TrustDomainInfoAuthInfoInternalAES *authinfo_internal = NULL;
2571 struct lsa_TrustDomainInfoInfoEx trustinfo = {
2572 .trust_attributes = 0,
2574 uint32_t out_version = 0;
2575 NTSTATUS status;
2576 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
2577 DATA_BLOB session_key = {
2578 .length = 0,
2580 bool ok;
2582 if (argc < 7) {
2583 printf("Usage: %s trust_name trust_dns_name trust_sid "
2584 "trust_directrion trust_type "
2585 "incoming_trustpw outgoing_trustpw\n",
2586 argv[0]);
2587 return NT_STATUS_OK;
2590 status = dcerpc_binding_handle_transport_session_key(
2591 b, mem_ctx, &session_key);
2592 if (!NT_STATUS_IS_OK(status)) {
2593 DBG_ERR("Could not retrieve session key: %s\n",
2594 nt_errstr(status));
2595 goto done;
2598 status = dcerpc_lsa_open_policy_fallback(b,
2599 mem_ctx,
2600 cli->srv_name_slash,
2601 true,
2602 SEC_FLAG_MAXIMUM_ALLOWED,
2603 &out_version,
2604 &out_revision_info,
2605 &handle,
2606 &result);
2607 if (any_nt_status_not_ok(status, result, &status)) {
2608 DBG_ERR("Could not open LSA connection: %s\n",
2609 nt_errstr(status));
2610 return status;
2613 init_lsa_StringLarge(&trustinfo.netbios_name, argv[1]);
2614 init_lsa_StringLarge(&trustinfo.domain_name, argv[2]);
2616 ok = string_to_sid(&sid, argv[3]);
2617 if (!ok) {
2618 status = NT_STATUS_INVALID_PARAMETER;
2619 DBG_ERR("Could not convert SID: %s\n", nt_errstr(status));
2620 goto done;
2622 trustinfo.sid = &sid;
2624 trustinfo.trust_direction = atoi(argv[4]);
2625 trustinfo.trust_type = atoi(argv[5]);
2627 ok = rpc_lsa_encrypt_trustdom_info_aes(mem_ctx,
2628 argv[6],
2629 argv[6],
2630 argv[7],
2631 argv[7],
2632 session_key,
2633 &authinfo_internal);
2634 if (!ok) {
2635 status = NT_STATUS_INVALID_PARAMETER;
2636 DBG_ERR("Could not encrypt trust information: %s\n",
2637 nt_errstr(status));
2638 goto done;
2641 status = dcerpc_lsa_CreateTrustedDomainEx3(b,
2642 mem_ctx,
2643 &handle,
2644 &trustinfo,
2645 authinfo_internal,
2646 SEC_FLAG_MAXIMUM_ALLOWED,
2647 &trustdom_handle,
2648 &result);
2649 if (any_nt_status_not_ok(status, result, &status)) {
2650 goto done;
2653 done:
2654 if (is_valid_policy_hnd(&trustdom_handle)) {
2655 dcerpc_lsa_Close(b, mem_ctx, &trustdom_handle, &result);
2658 if (is_valid_policy_hnd(&handle)) {
2659 dcerpc_lsa_Close(b, mem_ctx, &handle, &result);
2662 return status;
2665 static NTSTATUS cmd_lsa_create_trusted_domain_ex2(struct rpc_pipe_client *cli,
2666 TALLOC_CTX *mem_ctx,
2667 int argc,
2668 const char **argv)
2670 struct dcerpc_binding_handle *b = cli->binding_handle;
2671 struct policy_handle handle = {
2672 .handle_type = 0,
2674 struct policy_handle trustdom_handle = {
2675 .handle_type = 0,
2677 struct dom_sid sid = {
2678 .num_auths = 0,
2680 union lsa_revision_info out_revision_info = {
2681 .info1 = {
2682 .revision = 0,
2685 struct lsa_TrustDomainInfoAuthInfoInternal *authinfo_internal = NULL;
2686 struct lsa_TrustDomainInfoInfoEx trustinfo = {
2687 .trust_attributes = LSA_TRUST_ATTRIBUTE_USES_RC4_ENCRYPTION,
2689 uint32_t out_version = 0;
2690 NTSTATUS status;
2691 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
2692 DATA_BLOB session_key = {
2693 .length = 0,
2695 bool ok;
2697 if (argc < 7) {
2698 printf("Usage: %s trust_name trust_dns_name trust_sid "
2699 "trust_directrion trust_type "
2700 "incoming_trustpw outgoing_trustpw\n",
2701 argv[0]);
2702 return NT_STATUS_OK;
2705 status = dcerpc_binding_handle_transport_session_key(
2706 b, mem_ctx, &session_key);
2707 if (!NT_STATUS_IS_OK(status)) {
2708 DBG_ERR("Could not retrieve session key: %s\n",
2709 nt_errstr(status));
2710 goto done;
2713 status = dcerpc_lsa_open_policy_fallback(b,
2714 mem_ctx,
2715 cli->srv_name_slash,
2716 true,
2717 SEC_FLAG_MAXIMUM_ALLOWED,
2718 &out_version,
2719 &out_revision_info,
2720 &handle,
2721 &result);
2722 if (any_nt_status_not_ok(status, result, &status)) {
2723 DBG_ERR("Could not open LSA connection: %s\n",
2724 nt_errstr(status));
2725 return status;
2728 init_lsa_StringLarge(&trustinfo.netbios_name, argv[1]);
2729 init_lsa_StringLarge(&trustinfo.domain_name, argv[2]);
2731 ok = string_to_sid(&sid, argv[3]);
2732 if (!ok) {
2733 status = NT_STATUS_INVALID_PARAMETER;
2734 DBG_ERR("Could not convert SID: %s\n", nt_errstr(status));
2735 goto done;
2737 trustinfo.sid = &sid;
2739 trustinfo.trust_direction = atoi(argv[4]);
2740 trustinfo.trust_type = atoi(argv[5]);
2742 ok = rpc_lsa_encrypt_trustdom_info(mem_ctx,
2743 argv[6],
2744 argv[6],
2745 argv[7],
2746 argv[7],
2747 session_key,
2748 &authinfo_internal);
2749 if (!ok) {
2750 status = NT_STATUS_INVALID_PARAMETER;
2751 DBG_ERR("Could not encrypt trust information: %s\n",
2752 nt_errstr(status));
2753 goto done;
2756 status = dcerpc_lsa_CreateTrustedDomainEx2(b,
2757 mem_ctx,
2758 &handle,
2759 &trustinfo,
2760 authinfo_internal,
2761 SEC_FLAG_MAXIMUM_ALLOWED,
2762 &trustdom_handle,
2763 &result);
2764 if (any_nt_status_not_ok(status, result, &status)) {
2765 goto done;
2768 done:
2769 if (is_valid_policy_hnd(&trustdom_handle)) {
2770 dcerpc_lsa_Close(b, mem_ctx, &trustdom_handle, &result);
2773 if (is_valid_policy_hnd(&handle)) {
2774 dcerpc_lsa_Close(b, mem_ctx, &handle, &result);
2777 return status;
2780 static NTSTATUS cmd_lsa_delete_trusted_domain(struct rpc_pipe_client *cli,
2781 TALLOC_CTX *mem_ctx, int argc,
2782 const char **argv)
2784 NTSTATUS status, result;
2785 struct policy_handle handle, trustdom_handle;
2786 struct lsa_String name;
2787 struct dom_sid *sid = NULL;
2788 struct dcerpc_binding_handle *b = cli->binding_handle;
2789 union lsa_revision_info out_revision_info = {
2790 .info1 = {
2791 .revision = 0,
2794 uint32_t out_version = 0;
2796 if (argc < 2) {
2797 printf("Usage: %s name\n", argv[0]);
2798 return NT_STATUS_OK;
2801 status = dcerpc_lsa_open_policy_fallback(b,
2802 mem_ctx,
2803 cli->srv_name_slash,
2804 true,
2805 SEC_FLAG_MAXIMUM_ALLOWED,
2806 &out_version,
2807 &out_revision_info,
2808 &handle,
2809 &result);
2810 if (any_nt_status_not_ok(status, result, &status)) {
2811 return status;
2814 init_lsa_String(&name, argv[1]);
2816 status = dcerpc_lsa_OpenTrustedDomainByName(b, mem_ctx,
2817 &handle,
2818 name,
2819 SEC_FLAG_MAXIMUM_ALLOWED,
2820 &trustdom_handle,
2821 &result);
2822 if (NT_STATUS_IS_OK(status) && NT_STATUS_IS_OK(result)) {
2823 goto delete_object;
2827 uint32_t resume_handle = 0;
2828 struct lsa_DomainList domains;
2829 int i;
2831 status = dcerpc_lsa_EnumTrustDom(b, mem_ctx,
2832 &handle,
2833 &resume_handle,
2834 &domains,
2835 0xffff,
2836 &result);
2837 if (!NT_STATUS_IS_OK(status)) {
2838 goto done;
2840 if (!NT_STATUS_IS_OK(result)) {
2841 status = result;
2842 goto done;
2845 for (i=0; i < domains.count; i++) {
2846 if (strequal(domains.domains[i].name.string, argv[1])) {
2847 sid = domains.domains[i].sid;
2848 break;
2852 if (!sid) {
2853 return NT_STATUS_INVALID_SID;
2857 status = dcerpc_lsa_OpenTrustedDomain(b, mem_ctx,
2858 &handle,
2859 sid,
2860 SEC_FLAG_MAXIMUM_ALLOWED,
2861 &trustdom_handle,
2862 &result);
2863 if (!NT_STATUS_IS_OK(status)) {
2864 goto done;
2866 if (!NT_STATUS_IS_OK(result)) {
2867 status = result;
2868 goto done;
2871 delete_object:
2872 status = dcerpc_lsa_DeleteObject(b, mem_ctx,
2873 &trustdom_handle,
2874 &result);
2875 if (!NT_STATUS_IS_OK(status)) {
2876 goto done;
2878 if (!NT_STATUS_IS_OK(result)) {
2879 status = result;
2880 goto done;
2883 done:
2884 if (is_valid_policy_hnd(&trustdom_handle)) {
2885 dcerpc_lsa_Close(b, mem_ctx, &trustdom_handle, &result);
2888 if (is_valid_policy_hnd(&handle)) {
2889 dcerpc_lsa_Close(b, mem_ctx, &handle, &result);
2892 return status;
2896 /* List of commands exported by this module */
2898 struct cmd_set lsarpc_commands[] = {
2901 .name = "LSARPC",
2905 .name = "lsaquery",
2906 .returntype = RPC_RTYPE_NTSTATUS,
2907 .ntfn = cmd_lsa_query_info_policy,
2908 .wfn = NULL,
2909 .table = &ndr_table_lsarpc,
2910 .rpc_pipe = NULL,
2911 .description = "Query info policy",
2912 .usage = "",
2915 .name = "lookupsids",
2916 .returntype = RPC_RTYPE_NTSTATUS,
2917 .ntfn = cmd_lsa_lookup_sids,
2918 .wfn = NULL,
2919 .table = &ndr_table_lsarpc,
2920 .rpc_pipe = NULL,
2921 .description = "Convert SIDs to names",
2922 .usage = "",
2925 .name = "lookupsids3",
2926 .returntype = RPC_RTYPE_NTSTATUS,
2927 .ntfn = cmd_lsa_lookup_sids3,
2928 .wfn = NULL,
2929 .table = &ndr_table_lsarpc,
2930 .rpc_pipe = NULL,
2931 .description = "Convert SIDs to names",
2932 .usage = "",
2935 .name = "lookupsids_level",
2936 .returntype = RPC_RTYPE_NTSTATUS,
2937 .ntfn = cmd_lsa_lookup_sids_level,
2938 .wfn = NULL,
2939 .table = &ndr_table_lsarpc,
2940 .rpc_pipe = NULL,
2941 .description = "Convert SIDs to names",
2942 .usage = "",
2945 .name = "lookupnames",
2946 .returntype = RPC_RTYPE_NTSTATUS,
2947 .ntfn = cmd_lsa_lookup_names,
2948 .wfn = NULL,
2949 .table = &ndr_table_lsarpc,
2950 .rpc_pipe = NULL,
2951 .description = "Convert names to SIDs",
2952 .usage = "",
2955 .name = "lookupnames4",
2956 .returntype = RPC_RTYPE_NTSTATUS,
2957 .ntfn = cmd_lsa_lookup_names4,
2958 .wfn = NULL,
2959 .table = &ndr_table_lsarpc,
2960 .rpc_pipe = NULL,
2961 .description = "Convert names to SIDs",
2962 .usage = "",
2965 .name = "lookupnames_level",
2966 .returntype = RPC_RTYPE_NTSTATUS,
2967 .ntfn = cmd_lsa_lookup_names_level,
2968 .wfn = NULL,
2969 .table = &ndr_table_lsarpc,
2970 .rpc_pipe = NULL,
2971 .description = "Convert names to SIDs",
2972 .usage = "",
2975 .name = "enumtrust",
2976 .returntype = RPC_RTYPE_NTSTATUS,
2977 .ntfn = cmd_lsa_enum_trust_dom,
2978 .wfn = NULL,
2979 .table = &ndr_table_lsarpc,
2980 .rpc_pipe = NULL,
2981 .description = "Enumerate trusted domains",
2982 .usage = "Usage: [preferred max number] [enum context (0)]",
2985 .name = "enumprivs",
2986 .returntype = RPC_RTYPE_NTSTATUS,
2987 .ntfn = cmd_lsa_enum_privilege,
2988 .wfn = NULL,
2989 .table = &ndr_table_lsarpc,
2990 .rpc_pipe = NULL,
2991 .description = "Enumerate privileges",
2992 .usage = "",
2995 .name = "getdispname",
2996 .returntype = RPC_RTYPE_NTSTATUS,
2997 .ntfn = cmd_lsa_get_dispname,
2998 .wfn = NULL,
2999 .table = &ndr_table_lsarpc,
3000 .rpc_pipe = NULL,
3001 .description = "Get the privilege name",
3002 .usage = "",
3005 .name = "lsaenumsid",
3006 .returntype = RPC_RTYPE_NTSTATUS,
3007 .ntfn = cmd_lsa_enum_sids,
3008 .wfn = NULL,
3009 .table = &ndr_table_lsarpc,
3010 .rpc_pipe = NULL,
3011 .description = "Enumerate the LSA SIDS",
3012 .usage = "",
3015 .name = "lsacreateaccount",
3016 .returntype = RPC_RTYPE_NTSTATUS,
3017 .ntfn = cmd_lsa_create_account,
3018 .wfn = NULL,
3019 .table = &ndr_table_lsarpc,
3020 .rpc_pipe = NULL,
3021 .description = "Create a new lsa account",
3022 .usage = "",
3025 .name = "lsaenumprivsaccount",
3026 .returntype = RPC_RTYPE_NTSTATUS,
3027 .ntfn = cmd_lsa_enum_privsaccounts,
3028 .wfn = NULL,
3029 .table = &ndr_table_lsarpc,
3030 .rpc_pipe = NULL,
3031 .description = "Enumerate the privileges of an SID",
3032 .usage = "",
3035 .name = "lsaenumacctrights",
3036 .returntype = RPC_RTYPE_NTSTATUS,
3037 .ntfn = cmd_lsa_enum_acct_rights,
3038 .wfn = NULL,
3039 .table = &ndr_table_lsarpc,
3040 .rpc_pipe = NULL,
3041 .description = "Enumerate the rights of an SID",
3042 .usage = "",
3045 .name = "lsaaddpriv",
3046 .returntype = RPC_RTYPE_NTSTATUS,
3047 .ntfn = cmd_lsa_add_priv,
3048 .wfn = NULL,
3049 .table = &ndr_table_lsarpc,
3050 .rpc_pipe = NULL,
3051 .description = "Assign a privilege to a SID",
3052 .usage = "",
3055 .name = "lsadelpriv",
3056 .returntype = RPC_RTYPE_NTSTATUS,
3057 .ntfn = cmd_lsa_del_priv,
3058 .wfn = NULL,
3059 .table = &ndr_table_lsarpc,
3060 .rpc_pipe = NULL,
3061 .description = "Revoke a privilege from a SID",
3062 .usage = "",
3065 .name = "lsaaddacctrights",
3066 .returntype = RPC_RTYPE_NTSTATUS,
3067 .ntfn = cmd_lsa_add_acct_rights,
3068 .wfn = NULL,
3069 .table = &ndr_table_lsarpc,
3070 .rpc_pipe = NULL,
3071 .description = "Add rights to an account",
3072 .usage = "",
3075 .name = "lsaremoveacctrights",
3076 .returntype = RPC_RTYPE_NTSTATUS,
3077 .ntfn = cmd_lsa_remove_acct_rights,
3078 .wfn = NULL,
3079 .table = &ndr_table_lsarpc,
3080 .rpc_pipe = NULL,
3081 .description = "Remove rights from an account",
3082 .usage = "",
3085 .name = "lsalookupprivvalue",
3086 .returntype = RPC_RTYPE_NTSTATUS,
3087 .ntfn = cmd_lsa_lookup_priv_value,
3088 .wfn = NULL,
3089 .table = &ndr_table_lsarpc,
3090 .rpc_pipe = NULL,
3091 .description = "Get a privilege value given its name",
3092 .usage = "",
3095 .name = "lsaquerysecobj",
3096 .returntype = RPC_RTYPE_NTSTATUS,
3097 .ntfn = cmd_lsa_query_secobj,
3098 .wfn = NULL,
3099 .table = &ndr_table_lsarpc,
3100 .rpc_pipe = NULL,
3101 .description = "Query LSA security object",
3102 .usage = "",
3105 .name = "lsaquerytrustdominfo",
3106 .returntype = RPC_RTYPE_NTSTATUS,
3107 .ntfn = cmd_lsa_query_trustdominfo,
3108 .wfn = NULL,
3109 .table = &ndr_table_lsarpc,
3110 .rpc_pipe = NULL,
3111 .description = "Query LSA trusted domains info (given a SID)",
3112 .usage = "",
3115 .name = "lsaquerytrustdominfobyname",
3116 .returntype = RPC_RTYPE_NTSTATUS,
3117 .ntfn = cmd_lsa_query_trustdominfobyname,
3118 .wfn = NULL,
3119 .table = &ndr_table_lsarpc,
3120 .rpc_pipe = NULL,
3121 .description = "Query LSA trusted domains info (given a name), only works for Windows > 2k",
3122 .usage = "",
3125 .name = "lsaquerytrustdominfobysid",
3126 .returntype = RPC_RTYPE_NTSTATUS,
3127 .ntfn = cmd_lsa_query_trustdominfobysid,
3128 .wfn = NULL,
3129 .table = &ndr_table_lsarpc,
3130 .rpc_pipe = NULL,
3131 .description = "Query LSA trusted domains info (given a SID)",
3132 .usage = "",
3135 .name = "lsasettrustdominfo",
3136 .returntype = RPC_RTYPE_NTSTATUS,
3137 .ntfn = cmd_lsa_set_trustdominfo,
3138 .wfn = NULL,
3139 .table = &ndr_table_lsarpc,
3140 .rpc_pipe = NULL,
3141 .description = "Set LSA trusted domain info",
3142 .usage = "",
3145 .name = "getusername",
3146 .returntype = RPC_RTYPE_NTSTATUS,
3147 .ntfn = cmd_lsa_get_username,
3148 .wfn = NULL,
3149 .table = &ndr_table_lsarpc,
3150 .rpc_pipe = NULL,
3151 .description = "Get username",
3152 .usage = "",
3155 .name = "createsecret",
3156 .returntype = RPC_RTYPE_NTSTATUS,
3157 .ntfn = cmd_lsa_create_secret,
3158 .wfn = NULL,
3159 .table = &ndr_table_lsarpc,
3160 .rpc_pipe = NULL,
3161 .description = "Create Secret",
3162 .usage = "",
3165 .name = "deletesecret",
3166 .returntype = RPC_RTYPE_NTSTATUS,
3167 .ntfn = cmd_lsa_delete_secret,
3168 .wfn = NULL,
3169 .table = &ndr_table_lsarpc,
3170 .rpc_pipe = NULL,
3171 .description = "Delete Secret",
3172 .usage = "",
3175 .name = "querysecret",
3176 .returntype = RPC_RTYPE_NTSTATUS,
3177 .ntfn = cmd_lsa_query_secret,
3178 .wfn = NULL,
3179 .table = &ndr_table_lsarpc,
3180 .rpc_pipe = NULL,
3181 .description = "Query Secret",
3182 .usage = "",
3185 .name = "setsecret",
3186 .returntype = RPC_RTYPE_NTSTATUS,
3187 .ntfn = cmd_lsa_set_secret,
3188 .wfn = NULL,
3189 .table = &ndr_table_lsarpc,
3190 .rpc_pipe = NULL,
3191 .description = "Set Secret",
3192 .usage = "",
3195 .name = "retrieveprivatedata",
3196 .returntype = RPC_RTYPE_NTSTATUS,
3197 .ntfn = cmd_lsa_retrieve_private_data,
3198 .wfn = NULL,
3199 .table = &ndr_table_lsarpc,
3200 .rpc_pipe = NULL,
3201 .description = "Retrieve Private Data",
3202 .usage = "",
3205 .name = "storeprivatedata",
3206 .returntype = RPC_RTYPE_NTSTATUS,
3207 .ntfn = cmd_lsa_store_private_data,
3208 .wfn = NULL,
3209 .table = &ndr_table_lsarpc,
3210 .rpc_pipe = NULL,
3211 .description = "Store Private Data",
3212 .usage = "",
3215 .name = "createtrustdom",
3216 .returntype = RPC_RTYPE_NTSTATUS,
3217 .ntfn = cmd_lsa_create_trusted_domain,
3218 .wfn = NULL,
3219 .table = &ndr_table_lsarpc,
3220 .rpc_pipe = NULL,
3221 .description = "Create Trusted Domain",
3222 .usage = "",
3225 .name = "createtrustdomex2",
3226 .returntype = RPC_RTYPE_NTSTATUS,
3227 .ntfn = cmd_lsa_create_trusted_domain_ex2,
3228 .wfn = NULL,
3229 .table = &ndr_table_lsarpc,
3230 .rpc_pipe = NULL,
3231 .description = "Create Trusted Domain (Ex2 Variant)",
3232 .usage = "",
3235 .name = "createtrustdomex3",
3236 .returntype = RPC_RTYPE_NTSTATUS,
3237 .ntfn = cmd_lsa_create_trusted_domain_ex3,
3238 .wfn = NULL,
3239 .table = &ndr_table_lsarpc,
3240 .rpc_pipe = NULL,
3241 .description = "Create Trusted Domain (Ex3 Variant)",
3242 .usage = "",
3245 .name = "deletetrustdom",
3246 .returntype = RPC_RTYPE_NTSTATUS,
3247 .ntfn = cmd_lsa_delete_trusted_domain,
3248 .wfn = NULL,
3249 .table = &ndr_table_lsarpc,
3250 .rpc_pipe = NULL,
3251 .description = "Delete Trusted Domain",
3252 .usage = "",
3255 .name = NULL,