s3:vfs:gpfs: fix flapping offline: always get winAttrs from gpfs for is_offline
[Samba.git] / source3 / rpcclient / cmd_lsarpc.c
bloba6c3280c2fe34b0c5f5cf8f8cc5e752fa1f0912d
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, const char *name)
38 struct policy_handle pol;
39 enum lsa_SidType *sid_types;
40 NTSTATUS status, result;
41 struct dom_sid *sids;
42 struct dcerpc_binding_handle *b = cli->binding_handle;
44 /* maybe its a raw SID */
45 if (strncmp(name, "S-", 2) == 0 &&
46 string_to_sid(sid, name)) {
47 return NT_STATUS_OK;
50 status = rpccli_lsa_open_policy(cli, mem_ctx, True,
51 SEC_FLAG_MAXIMUM_ALLOWED,
52 &pol);
53 if (!NT_STATUS_IS_OK(status))
54 goto done;
56 status = rpccli_lsa_lookup_names(cli, mem_ctx, &pol, 1, &name, NULL, 1, &sids, &sid_types);
57 if (!NT_STATUS_IS_OK(status))
58 goto done;
60 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
62 *sid = sids[0];
64 done:
65 return status;
68 static void display_query_info_1(struct lsa_AuditLogInfo *r)
70 d_printf("percent_full:\t%d\n", r->percent_full);
71 d_printf("maximum_log_size:\t%d\n", r->maximum_log_size);
72 d_printf("retention_time:\t%lld\n", (long long)r->retention_time);
73 d_printf("shutdown_in_progress:\t%d\n", r->shutdown_in_progress);
74 d_printf("time_to_shutdown:\t%lld\n", (long long)r->time_to_shutdown);
75 d_printf("next_audit_record:\t%d\n", r->next_audit_record);
78 static void display_query_info_2(struct lsa_AuditEventsInfo *r)
80 int i;
81 d_printf("Auditing enabled:\t%d\n", r->auditing_mode);
82 d_printf("Auditing categories:\t%d\n", r->count);
83 d_printf("Auditsettings:\n");
84 for (i=0; i<r->count; i++) {
85 const char *val = audit_policy_str(talloc_tos(), r->settings[i]);
86 const char *policy = audit_description_str(i);
87 d_printf("%s:\t%s\n", policy, val);
91 static void display_query_info_3(struct lsa_DomainInfo *r)
93 d_printf("Domain Name: %s\n", r->name.string);
94 d_printf("Domain Sid: %s\n", sid_string_tos(r->sid));
97 static void display_query_info_5(struct lsa_DomainInfo *r)
99 d_printf("Domain Name: %s\n", r->name.string);
100 d_printf("Domain Sid: %s\n", sid_string_tos(r->sid));
103 static void display_query_info_10(struct lsa_AuditFullSetInfo *r)
105 d_printf("Shutdown on full: %d\n", r->shutdown_on_full);
108 static void display_query_info_11(struct lsa_AuditFullQueryInfo *r)
110 d_printf("Shutdown on full: %d\n", r->shutdown_on_full);
111 d_printf("Log is full: %d\n", r->log_is_full);
114 static void display_query_info_12(struct lsa_DnsDomainInfo *r)
116 d_printf("Domain NetBios Name: %s\n", r->name.string);
117 d_printf("Domain DNS Name: %s\n", r->dns_domain.string);
118 d_printf("Domain Forest Name: %s\n", r->dns_forest.string);
119 d_printf("Domain Sid: %s\n", sid_string_tos(r->sid));
120 d_printf("Domain GUID: %s\n", GUID_string(talloc_tos(),
121 &r->domain_guid));
124 static void display_lsa_query_info(union lsa_PolicyInformation *info,
125 enum lsa_PolicyInfo level)
127 switch (level) {
128 case 1:
129 display_query_info_1(&info->audit_log);
130 break;
131 case 2:
132 display_query_info_2(&info->audit_events);
133 break;
134 case 3:
135 display_query_info_3(&info->domain);
136 break;
137 case 5:
138 display_query_info_5(&info->account_domain);
139 break;
140 case 10:
141 display_query_info_10(&info->auditfullset);
142 break;
143 case 11:
144 display_query_info_11(&info->auditfullquery);
145 break;
146 case 12:
147 display_query_info_12(&info->dns);
148 break;
149 default:
150 printf("can't display info level: %d\n", level);
151 break;
155 static NTSTATUS cmd_lsa_query_info_policy(struct rpc_pipe_client *cli,
156 TALLOC_CTX *mem_ctx, int argc,
157 const char **argv)
159 struct policy_handle pol;
160 NTSTATUS status, result;
161 union lsa_PolicyInformation *info = NULL;
162 struct dcerpc_binding_handle *b = cli->binding_handle;
164 uint32 info_class = 3;
166 if (argc > 2) {
167 printf("Usage: %s [info_class]\n", argv[0]);
168 return NT_STATUS_OK;
171 if (argc == 2)
172 info_class = atoi(argv[1]);
174 switch (info_class) {
175 case 12:
176 status = rpccli_lsa_open_policy2(cli, mem_ctx, True,
177 SEC_FLAG_MAXIMUM_ALLOWED,
178 &pol);
180 if (!NT_STATUS_IS_OK(status))
181 goto done;
183 status = dcerpc_lsa_QueryInfoPolicy2(b, mem_ctx,
184 &pol,
185 info_class,
186 &info,
187 &result);
188 break;
189 default:
190 status = rpccli_lsa_open_policy(cli, mem_ctx, True,
191 SEC_FLAG_MAXIMUM_ALLOWED,
192 &pol);
194 if (!NT_STATUS_IS_OK(status))
195 goto done;
197 status = dcerpc_lsa_QueryInfoPolicy(b, mem_ctx,
198 &pol,
199 info_class,
200 &info,
201 &result);
204 if (!NT_STATUS_IS_OK(status)) {
205 goto done;
207 status = result;
208 if (NT_STATUS_IS_OK(result)) {
209 display_lsa_query_info(info, info_class);
212 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
214 done:
215 return status;
218 /* Resolve a list of names to a list of sids */
220 static NTSTATUS cmd_lsa_lookup_names(struct rpc_pipe_client *cli,
221 TALLOC_CTX *mem_ctx, int argc,
222 const char **argv)
224 struct policy_handle pol;
225 NTSTATUS status, result;
226 struct dom_sid *sids;
227 enum lsa_SidType *types;
228 int i;
229 struct dcerpc_binding_handle *b = cli->binding_handle;
231 if (argc == 1) {
232 printf("Usage: %s [name1 [name2 [...]]]\n", argv[0]);
233 return NT_STATUS_OK;
236 status = rpccli_lsa_open_policy(cli, mem_ctx, True,
237 SEC_FLAG_MAXIMUM_ALLOWED,
238 &pol);
240 if (!NT_STATUS_IS_OK(status))
241 goto done;
243 status = rpccli_lsa_lookup_names(cli, mem_ctx, &pol, argc - 1,
244 (const char**)(argv + 1), NULL, 1, &sids, &types);
246 if (!NT_STATUS_IS_OK(status) && NT_STATUS_V(status) !=
247 NT_STATUS_V(STATUS_SOME_UNMAPPED))
248 goto done;
250 status = NT_STATUS_OK;
252 /* Print results */
254 for (i = 0; i < (argc - 1); i++) {
255 fstring sid_str;
256 sid_to_fstring(sid_str, &sids[i]);
257 printf("%s %s (%s: %d)\n", argv[i + 1], sid_str,
258 sid_type_lookup(types[i]), types[i]);
261 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
263 done:
264 return status;
267 /* Resolve a list of names to a list of sids */
269 static NTSTATUS cmd_lsa_lookup_names_level(struct rpc_pipe_client *cli,
270 TALLOC_CTX *mem_ctx, int argc,
271 const char **argv)
273 struct policy_handle pol;
274 NTSTATUS status, result;
275 struct dom_sid *sids;
276 enum lsa_SidType *types;
277 int i, level;
278 struct dcerpc_binding_handle *b = cli->binding_handle;
280 if (argc < 3) {
281 printf("Usage: %s [level] [name1 [name2 [...]]]\n", argv[0]);
282 return NT_STATUS_OK;
285 status = rpccli_lsa_open_policy(cli, mem_ctx, True,
286 SEC_FLAG_MAXIMUM_ALLOWED,
287 &pol);
289 if (!NT_STATUS_IS_OK(status))
290 goto done;
292 level = atoi(argv[1]);
294 status = rpccli_lsa_lookup_names(cli, mem_ctx, &pol, argc - 2,
295 (const char**)(argv + 2), NULL, level, &sids, &types);
297 if (!NT_STATUS_IS_OK(status) && NT_STATUS_V(status) !=
298 NT_STATUS_V(STATUS_SOME_UNMAPPED))
299 goto done;
301 status = NT_STATUS_OK;
303 /* Print results */
305 for (i = 0; i < (argc - 2); i++) {
306 fstring sid_str;
307 sid_to_fstring(sid_str, &sids[i]);
308 printf("%s %s (%s: %d)\n", argv[i + 2], sid_str,
309 sid_type_lookup(types[i]), types[i]);
312 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
314 done:
315 return status;
318 static NTSTATUS cmd_lsa_lookup_names4(struct rpc_pipe_client *cli,
319 TALLOC_CTX *mem_ctx, int argc,
320 const char **argv)
322 NTSTATUS status, result;
324 uint32_t num_names;
325 struct lsa_String *names;
326 struct lsa_RefDomainList *domains = NULL;
327 struct lsa_TransSidArray3 sids;
328 uint32_t count = 0;
329 int i;
330 struct dcerpc_binding_handle *b = cli->binding_handle;
332 if (argc == 1) {
333 printf("Usage: %s [name1 [name2 [...]]]\n", argv[0]);
334 return NT_STATUS_OK;
337 ZERO_STRUCT(sids);
339 num_names = argc-1;
340 names = talloc_array(mem_ctx, struct lsa_String, num_names);
341 NT_STATUS_HAVE_NO_MEMORY(names);
343 for (i=0; i < num_names; i++) {
344 init_lsa_String(&names[i], argv[i+1]);
347 status = dcerpc_lsa_LookupNames4(b, mem_ctx,
348 num_names,
349 names,
350 &domains,
351 &sids,
353 &count,
356 &result);
357 if (!NT_STATUS_IS_OK(status)) {
358 return status;
360 if (!NT_STATUS_IS_OK(result)) {
361 return result;
364 if (sids.count != num_names) {
365 return NT_STATUS_INVALID_NETWORK_RESPONSE;
368 for (i = 0; i < sids.count; i++) {
369 fstring sid_str;
370 sid_to_fstring(sid_str, sids.sids[i].sid);
371 printf("%s %s (%s: %d)\n", argv[i+1], sid_str,
372 sid_type_lookup(sids.sids[i].sid_type),
373 sids.sids[i].sid_type);
376 return status;
379 /* Resolve a list of SIDs to a list of names */
381 static NTSTATUS cmd_lsa_lookup_sids(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
382 int argc, const char **argv)
384 struct policy_handle pol;
385 NTSTATUS status, result;
386 struct dom_sid *sids;
387 char **domains;
388 char **names;
389 enum lsa_SidType *types;
390 int i;
391 struct dcerpc_binding_handle *b = cli->binding_handle;
393 if (argc == 1) {
394 printf("Usage: %s [sid1 [sid2 [...]]]\n", argv[0]);
395 return NT_STATUS_OK;
398 status = rpccli_lsa_open_policy(cli, mem_ctx, True,
399 SEC_FLAG_MAXIMUM_ALLOWED,
400 &pol);
402 if (!NT_STATUS_IS_OK(status))
403 goto done;
405 /* Convert arguments to sids */
407 sids = talloc_array(mem_ctx, struct dom_sid, argc - 1);
409 if (!sids) {
410 printf("could not allocate memory for %d sids\n", argc - 1);
411 goto done;
414 for (i = 0; i < argc - 1; i++)
415 if (!string_to_sid(&sids[i], argv[i + 1])) {
416 status = NT_STATUS_INVALID_SID;
417 goto done;
420 /* Lookup the SIDs */
422 status = rpccli_lsa_lookup_sids(cli, mem_ctx, &pol, argc - 1, sids,
423 &domains, &names, &types);
425 if (!NT_STATUS_IS_OK(status) && NT_STATUS_V(status) !=
426 NT_STATUS_V(STATUS_SOME_UNMAPPED))
427 goto done;
429 status = NT_STATUS_OK;
431 /* Print results */
433 for (i = 0; i < (argc - 1); i++) {
434 fstring sid_str;
436 sid_to_fstring(sid_str, &sids[i]);
437 if (types[i] == SID_NAME_DOMAIN) {
438 printf("%s %s (%d)\n", sid_str,
439 domains[i] ? domains[i] : "*unknown*",
440 types[i]);
441 } else {
442 printf("%s %s\\%s (%d)\n", sid_str,
443 domains[i] ? domains[i] : "*unknown*",
444 names[i] ? names[i] : "*unknown*",
445 types[i]);
449 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
451 done:
452 return status;
455 /* Resolve a list of SIDs to a list of names */
457 static NTSTATUS cmd_lsa_lookup_sids3(struct rpc_pipe_client *cli,
458 TALLOC_CTX *mem_ctx,
459 int argc, const char **argv)
461 NTSTATUS status = NT_STATUS_UNSUCCESSFUL, result;
462 int i;
463 struct lsa_SidArray sids;
464 struct lsa_RefDomainList *domains = NULL;
465 struct lsa_TransNameArray2 names;
466 uint32_t count = 0;
467 struct dcerpc_binding_handle *b = cli->binding_handle;
469 if (argc == 1) {
470 printf("Usage: %s [sid1 [sid2 [...]]]\n", argv[0]);
471 return NT_STATUS_OK;
474 ZERO_STRUCT(names);
476 /* Convert arguments to sids */
478 sids.num_sids = argc-1;
479 sids.sids = talloc_array(mem_ctx, struct lsa_SidPtr, sids.num_sids);
480 if (!sids.sids) {
481 printf("could not allocate memory for %d sids\n", sids.num_sids);
482 goto done;
485 for (i = 0; i < sids.num_sids; i++) {
486 sids.sids[i].sid = talloc(sids.sids, struct dom_sid);
487 if (sids.sids[i].sid == NULL) {
488 status = NT_STATUS_NO_MEMORY;
489 goto done;
491 if (!string_to_sid(sids.sids[i].sid, argv[i+1])) {
492 status = NT_STATUS_INVALID_SID;
493 goto done;
497 /* Lookup the SIDs */
498 status = dcerpc_lsa_LookupSids3(b, mem_ctx,
499 &sids,
500 &domains,
501 &names,
503 &count,
506 &result);
507 if (!NT_STATUS_IS_OK(status)) {
508 goto done;
510 if (!NT_STATUS_IS_OK(result) && NT_STATUS_V(result) !=
511 NT_STATUS_V(STATUS_SOME_UNMAPPED)) {
512 status = result;
513 goto done;
516 status = NT_STATUS_OK;
518 /* Print results */
520 for (i = 0; i < names.count; i++) {
521 fstring sid_str;
523 if (i >= sids.num_sids) {
524 break;
526 sid_to_fstring(sid_str, sids.sids[i].sid);
527 printf("%s %s (%d)\n", sid_str,
528 names.names[i].name.string,
529 names.names[i].sid_type);
532 done:
533 return status;
537 /* Enumerate list of trusted domains */
539 static NTSTATUS cmd_lsa_enum_trust_dom(struct rpc_pipe_client *cli,
540 TALLOC_CTX *mem_ctx, int argc,
541 const char **argv)
543 struct policy_handle pol;
544 NTSTATUS status, result;
545 struct lsa_DomainList domain_list;
546 struct dcerpc_binding_handle *b = cli->binding_handle;
548 /* defaults, but may be changed using params */
549 uint32 enum_ctx = 0;
550 int i;
551 uint32_t max_size = (uint32_t)-1;
553 if (argc > 2) {
554 printf("Usage: %s [enum context (0)]\n", argv[0]);
555 return NT_STATUS_OK;
558 if (argc == 2 && argv[1]) {
559 enum_ctx = atoi(argv[2]);
562 status = rpccli_lsa_open_policy(cli, mem_ctx, True,
563 LSA_POLICY_VIEW_LOCAL_INFORMATION,
564 &pol);
566 if (!NT_STATUS_IS_OK(status))
567 goto done;
569 status = STATUS_MORE_ENTRIES;
571 while (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) {
573 /* Lookup list of trusted domains */
575 status = dcerpc_lsa_EnumTrustDom(b, mem_ctx,
576 &pol,
577 &enum_ctx,
578 &domain_list,
579 max_size,
580 &result);
581 if (!NT_STATUS_IS_OK(status)) {
582 goto done;
584 if (!NT_STATUS_IS_OK(result) &&
585 !NT_STATUS_EQUAL(result, NT_STATUS_NO_MORE_ENTRIES) &&
586 !NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)) {
587 status = result;
588 goto done;
591 /* Print results: list of names and sids returned in this
592 * response. */
593 for (i = 0; i < domain_list.count; i++) {
594 fstring sid_str;
596 sid_to_fstring(sid_str, domain_list.domains[i].sid);
597 printf("%s %s\n",
598 domain_list.domains[i].name.string ?
599 domain_list.domains[i].name.string : "*unknown*",
600 sid_str);
604 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
605 done:
606 return status;
609 /* Enumerates privileges */
611 static NTSTATUS cmd_lsa_enum_privilege(struct rpc_pipe_client *cli,
612 TALLOC_CTX *mem_ctx, int argc,
613 const char **argv)
615 struct policy_handle pol;
616 NTSTATUS status, result;
617 struct lsa_PrivArray priv_array;
618 struct dcerpc_binding_handle *b = cli->binding_handle;
620 uint32 enum_context=0;
621 uint32 pref_max_length=0x1000;
622 int i;
624 if (argc > 3) {
625 printf("Usage: %s [enum context] [max length]\n", argv[0]);
626 return NT_STATUS_OK;
629 if (argc>=2)
630 enum_context=atoi(argv[1]);
632 if (argc==3)
633 pref_max_length=atoi(argv[2]);
635 status = rpccli_lsa_open_policy(cli, mem_ctx, True,
636 SEC_FLAG_MAXIMUM_ALLOWED,
637 &pol);
639 if (!NT_STATUS_IS_OK(status))
640 goto done;
642 status = dcerpc_lsa_EnumPrivs(b, mem_ctx,
643 &pol,
644 &enum_context,
645 &priv_array,
646 pref_max_length,
647 &result);
648 if (!NT_STATUS_IS_OK(status))
649 goto done;
650 if (!NT_STATUS_IS_OK(result)) {
651 status = result;
652 goto done;
655 /* Print results */
656 printf("found %d privileges\n\n", priv_array.count);
658 for (i = 0; i < priv_array.count; i++) {
659 printf("%s \t\t%d:%d (0x%x:0x%x)\n",
660 priv_array.privs[i].name.string ? priv_array.privs[i].name.string : "*unknown*",
661 priv_array.privs[i].luid.high,
662 priv_array.privs[i].luid.low,
663 priv_array.privs[i].luid.high,
664 priv_array.privs[i].luid.low);
667 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
668 done:
669 return status;
672 /* Get privilege name */
674 static NTSTATUS cmd_lsa_get_dispname(struct rpc_pipe_client *cli,
675 TALLOC_CTX *mem_ctx, int argc,
676 const char **argv)
678 struct policy_handle pol;
679 NTSTATUS status, result;
680 struct dcerpc_binding_handle *b = cli->binding_handle;
682 uint16 lang_id=0;
683 uint16 lang_id_sys=0;
684 uint16 lang_id_desc;
685 struct lsa_String lsa_name;
686 struct lsa_StringLarge *description = NULL;
688 if (argc != 2) {
689 printf("Usage: %s privilege name\n", argv[0]);
690 return NT_STATUS_OK;
693 status = rpccli_lsa_open_policy(cli, mem_ctx, True,
694 SEC_FLAG_MAXIMUM_ALLOWED,
695 &pol);
697 if (!NT_STATUS_IS_OK(status))
698 goto done;
700 init_lsa_String(&lsa_name, argv[1]);
702 status = dcerpc_lsa_LookupPrivDisplayName(b, mem_ctx,
703 &pol,
704 &lsa_name,
705 lang_id,
706 lang_id_sys,
707 &description,
708 &lang_id_desc,
709 &result);
710 if (!NT_STATUS_IS_OK(status))
711 goto done;
712 if (!NT_STATUS_IS_OK(result)) {
713 status = result;
714 goto done;
717 /* Print results */
718 printf("%s -> %s (language: 0x%x)\n", argv[1], description->string, lang_id_desc);
720 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
721 done:
722 return status;
725 /* Enumerate the LSA SIDS */
727 static NTSTATUS cmd_lsa_enum_sids(struct rpc_pipe_client *cli,
728 TALLOC_CTX *mem_ctx, int argc,
729 const char **argv)
731 struct policy_handle pol;
732 NTSTATUS status, result;
733 struct dcerpc_binding_handle *b = cli->binding_handle;
735 uint32 enum_context=0;
736 uint32 pref_max_length=0x1000;
737 struct lsa_SidArray sid_array;
738 int i;
740 if (argc > 3) {
741 printf("Usage: %s [enum context] [max length]\n", argv[0]);
742 return NT_STATUS_OK;
745 if (argc>=2)
746 enum_context=atoi(argv[1]);
748 if (argc==3)
749 pref_max_length=atoi(argv[2]);
751 status = rpccli_lsa_open_policy(cli, mem_ctx, True,
752 SEC_FLAG_MAXIMUM_ALLOWED,
753 &pol);
755 if (!NT_STATUS_IS_OK(status))
756 goto done;
758 status = dcerpc_lsa_EnumAccounts(b, mem_ctx,
759 &pol,
760 &enum_context,
761 &sid_array,
762 pref_max_length,
763 &result);
764 if (!NT_STATUS_IS_OK(status))
765 goto done;
766 if (!NT_STATUS_IS_OK(result)) {
767 status = result;
768 goto done;
771 /* Print results */
772 printf("found %d SIDs\n\n", sid_array.num_sids);
774 for (i = 0; i < sid_array.num_sids; i++) {
775 fstring sid_str;
777 sid_to_fstring(sid_str, sid_array.sids[i].sid);
778 printf("%s\n", sid_str);
781 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
782 done:
783 return status;
786 /* Create a new account */
788 static NTSTATUS cmd_lsa_create_account(struct rpc_pipe_client *cli,
789 TALLOC_CTX *mem_ctx, int argc,
790 const char **argv)
792 struct policy_handle dom_pol;
793 struct policy_handle user_pol;
794 NTSTATUS status, result;
795 uint32 des_access = 0x000f000f;
796 struct dcerpc_binding_handle *b = cli->binding_handle;
798 struct dom_sid sid;
800 if (argc != 2 ) {
801 printf("Usage: %s SID\n", argv[0]);
802 return NT_STATUS_OK;
805 status = name_to_sid(cli, mem_ctx, &sid, argv[1]);
806 if (!NT_STATUS_IS_OK(status))
807 goto done;
809 status = rpccli_lsa_open_policy2(cli, mem_ctx, True,
810 SEC_FLAG_MAXIMUM_ALLOWED,
811 &dom_pol);
813 if (!NT_STATUS_IS_OK(status))
814 goto done;
816 status = dcerpc_lsa_CreateAccount(b, mem_ctx,
817 &dom_pol,
818 &sid,
819 des_access,
820 &user_pol,
821 &result);
822 if (!NT_STATUS_IS_OK(status))
823 goto done;
824 if (!NT_STATUS_IS_OK(result)) {
825 status = result;
826 goto done;
829 printf("Account for SID %s successfully created\n\n", argv[1]);
830 status = NT_STATUS_OK;
832 dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result);
833 done:
834 return status;
838 /* Enumerate the privileges of an SID */
840 static NTSTATUS cmd_lsa_enum_privsaccounts(struct rpc_pipe_client *cli,
841 TALLOC_CTX *mem_ctx, int argc,
842 const char **argv)
844 struct policy_handle dom_pol;
845 struct policy_handle user_pol;
846 NTSTATUS status, result;
847 uint32 access_desired = 0x000f000f;
848 struct dom_sid sid;
849 struct lsa_PrivilegeSet *privs = NULL;
850 int i;
851 struct dcerpc_binding_handle *b = cli->binding_handle;
853 if (argc != 2 ) {
854 printf("Usage: %s SID\n", argv[0]);
855 return NT_STATUS_OK;
858 status = name_to_sid(cli, mem_ctx, &sid, argv[1]);
859 if (!NT_STATUS_IS_OK(status))
860 goto done;
862 status = rpccli_lsa_open_policy2(cli, mem_ctx, True,
863 SEC_FLAG_MAXIMUM_ALLOWED,
864 &dom_pol);
866 if (!NT_STATUS_IS_OK(status))
867 goto done;
869 status = dcerpc_lsa_OpenAccount(b, mem_ctx,
870 &dom_pol,
871 &sid,
872 access_desired,
873 &user_pol,
874 &result);
875 if (!NT_STATUS_IS_OK(status))
876 goto done;
877 if (!NT_STATUS_IS_OK(result)) {
878 status = result;
879 goto done;
882 status = dcerpc_lsa_EnumPrivsAccount(b, mem_ctx,
883 &user_pol,
884 &privs,
885 &result);
886 if (!NT_STATUS_IS_OK(status))
887 goto done;
888 if (!NT_STATUS_IS_OK(result)) {
889 status = result;
890 goto done;
893 /* Print results */
894 printf("found %d privileges for SID %s\n\n", privs->count, argv[1]);
895 printf("high\tlow\tattribute\n");
897 for (i = 0; i < privs->count; i++) {
898 printf("%u\t%u\t%u\n",
899 privs->set[i].luid.high,
900 privs->set[i].luid.low,
901 privs->set[i].attribute);
904 dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result);
905 done:
906 return status;
910 /* Enumerate the privileges of an SID via LsaEnumerateAccountRights */
912 static NTSTATUS cmd_lsa_enum_acct_rights(struct rpc_pipe_client *cli,
913 TALLOC_CTX *mem_ctx, int argc,
914 const char **argv)
916 struct policy_handle dom_pol;
917 NTSTATUS status, result;
918 struct dom_sid sid;
919 struct lsa_RightSet rights;
920 struct dcerpc_binding_handle *b = cli->binding_handle;
922 int i;
924 if (argc != 2 ) {
925 printf("Usage: %s SID\n", argv[0]);
926 return NT_STATUS_OK;
929 status = name_to_sid(cli, mem_ctx, &sid, argv[1]);
930 if (!NT_STATUS_IS_OK(status))
931 goto done;
933 status = rpccli_lsa_open_policy2(cli, mem_ctx, True,
934 SEC_FLAG_MAXIMUM_ALLOWED,
935 &dom_pol);
937 if (!NT_STATUS_IS_OK(status))
938 goto done;
940 status = dcerpc_lsa_EnumAccountRights(b, mem_ctx,
941 &dom_pol,
942 &sid,
943 &rights,
944 &result);
945 if (!NT_STATUS_IS_OK(status))
946 goto done;
947 if (!NT_STATUS_IS_OK(result)) {
948 status = result;
949 goto done;
952 printf("found %d privileges for SID %s\n", rights.count,
953 sid_string_tos(&sid));
955 for (i = 0; i < rights.count; i++) {
956 printf("\t%s\n", rights.names[i].string);
959 dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result);
960 done:
961 return status;
965 /* add some privileges to a SID via LsaAddAccountRights */
967 static NTSTATUS cmd_lsa_add_acct_rights(struct rpc_pipe_client *cli,
968 TALLOC_CTX *mem_ctx, int argc,
969 const char **argv)
971 struct policy_handle dom_pol;
972 NTSTATUS status, result;
973 struct lsa_RightSet rights;
974 struct dom_sid sid;
975 int i;
976 struct dcerpc_binding_handle *b = cli->binding_handle;
978 if (argc < 3 ) {
979 printf("Usage: %s SID [rights...]\n", argv[0]);
980 return NT_STATUS_OK;
983 status = name_to_sid(cli, mem_ctx, &sid, argv[1]);
984 if (!NT_STATUS_IS_OK(status))
985 goto done;
987 status = rpccli_lsa_open_policy2(cli, mem_ctx, True,
988 SEC_FLAG_MAXIMUM_ALLOWED,
989 &dom_pol);
991 if (!NT_STATUS_IS_OK(status))
992 goto done;
994 rights.count = argc-2;
995 rights.names = talloc_array(mem_ctx, struct lsa_StringLarge,
996 rights.count);
997 if (!rights.names) {
998 return NT_STATUS_NO_MEMORY;
1001 for (i=0; i<argc-2; i++) {
1002 init_lsa_StringLarge(&rights.names[i], argv[i+2]);
1005 status = dcerpc_lsa_AddAccountRights(b, mem_ctx,
1006 &dom_pol,
1007 &sid,
1008 &rights,
1009 &result);
1010 if (!NT_STATUS_IS_OK(status))
1011 goto done;
1012 if (!NT_STATUS_IS_OK(result)) {
1013 status = result;
1014 goto done;
1017 dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result);
1018 done:
1019 return status;
1023 /* remove some privileges to a SID via LsaRemoveAccountRights */
1025 static NTSTATUS cmd_lsa_remove_acct_rights(struct rpc_pipe_client *cli,
1026 TALLOC_CTX *mem_ctx, int argc,
1027 const char **argv)
1029 struct policy_handle dom_pol;
1030 NTSTATUS status, result;
1031 struct lsa_RightSet rights;
1032 struct dom_sid sid;
1033 int i;
1034 struct dcerpc_binding_handle *b = cli->binding_handle;
1036 if (argc < 3 ) {
1037 printf("Usage: %s SID [rights...]\n", argv[0]);
1038 return NT_STATUS_OK;
1041 status = name_to_sid(cli, mem_ctx, &sid, argv[1]);
1042 if (!NT_STATUS_IS_OK(status))
1043 goto done;
1045 status = rpccli_lsa_open_policy2(cli, mem_ctx, True,
1046 SEC_FLAG_MAXIMUM_ALLOWED,
1047 &dom_pol);
1049 if (!NT_STATUS_IS_OK(status))
1050 goto done;
1052 rights.count = argc-2;
1053 rights.names = talloc_array(mem_ctx, struct lsa_StringLarge,
1054 rights.count);
1055 if (!rights.names) {
1056 return NT_STATUS_NO_MEMORY;
1059 for (i=0; i<argc-2; i++) {
1060 init_lsa_StringLarge(&rights.names[i], argv[i+2]);
1063 status = dcerpc_lsa_RemoveAccountRights(b, mem_ctx,
1064 &dom_pol,
1065 &sid,
1066 false,
1067 &rights,
1068 &result);
1069 if (!NT_STATUS_IS_OK(status))
1070 goto done;
1071 if (!NT_STATUS_IS_OK(result)) {
1072 status = result;
1073 goto done;
1076 dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result);
1078 done:
1079 return status;
1083 /* Get a privilege value given its name */
1085 static NTSTATUS cmd_lsa_lookup_priv_value(struct rpc_pipe_client *cli,
1086 TALLOC_CTX *mem_ctx, int argc,
1087 const char **argv)
1089 struct policy_handle pol;
1090 NTSTATUS status, result;
1091 struct lsa_LUID luid;
1092 struct lsa_String name;
1093 struct dcerpc_binding_handle *b = cli->binding_handle;
1095 if (argc != 2 ) {
1096 printf("Usage: %s name\n", argv[0]);
1097 return NT_STATUS_OK;
1100 status = rpccli_lsa_open_policy2(cli, mem_ctx, True,
1101 SEC_FLAG_MAXIMUM_ALLOWED,
1102 &pol);
1104 if (!NT_STATUS_IS_OK(status))
1105 goto done;
1107 init_lsa_String(&name, argv[1]);
1109 status = dcerpc_lsa_LookupPrivValue(b, mem_ctx,
1110 &pol,
1111 &name,
1112 &luid,
1113 &result);
1114 if (!NT_STATUS_IS_OK(status))
1115 goto done;
1116 if (!NT_STATUS_IS_OK(result)) {
1117 status = result;
1118 goto done;
1121 /* Print results */
1123 printf("%u:%u (0x%x:0x%x)\n", luid.high, luid.low, luid.high, luid.low);
1125 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
1126 done:
1127 return status;
1130 /* Query LSA security object */
1132 static NTSTATUS cmd_lsa_query_secobj(struct rpc_pipe_client *cli,
1133 TALLOC_CTX *mem_ctx, int argc,
1134 const char **argv)
1136 struct policy_handle pol;
1137 NTSTATUS status, result;
1138 struct sec_desc_buf *sdb;
1139 uint32 sec_info = SECINFO_DACL;
1140 struct dcerpc_binding_handle *b = cli->binding_handle;
1142 if (argc < 1 || argc > 2) {
1143 printf("Usage: %s [sec_info]\n", argv[0]);
1144 return NT_STATUS_OK;
1147 status = rpccli_lsa_open_policy2(cli, mem_ctx, True,
1148 SEC_FLAG_MAXIMUM_ALLOWED,
1149 &pol);
1151 if (argc == 2)
1152 sscanf(argv[1], "%x", &sec_info);
1154 if (!NT_STATUS_IS_OK(status))
1155 goto done;
1157 status = dcerpc_lsa_QuerySecurity(b, mem_ctx,
1158 &pol,
1159 sec_info,
1160 &sdb,
1161 &result);
1162 if (!NT_STATUS_IS_OK(status))
1163 goto done;
1164 if (!NT_STATUS_IS_OK(result)) {
1165 status = result;
1166 goto done;
1169 /* Print results */
1171 display_sec_desc(sdb->sd);
1173 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
1174 done:
1175 return status;
1178 static void display_trust_dom_info_4(struct lsa_TrustDomainInfoPassword *p,
1179 DATA_BLOB session_key)
1181 char *pwd, *pwd_old;
1183 DATA_BLOB data = data_blob_const(p->password->data, p->password->length);
1184 DATA_BLOB data_old = data_blob_const(p->old_password->data, p->old_password->length);
1186 pwd = sess_decrypt_string(talloc_tos(), &data, &session_key);
1187 pwd_old = sess_decrypt_string(talloc_tos(), &data_old, &session_key);
1189 d_printf("Password:\t%s\n", pwd);
1190 d_printf("Old Password:\t%s\n", pwd_old);
1192 talloc_free(pwd);
1193 talloc_free(pwd_old);
1196 static void display_trust_dom_info(TALLOC_CTX *mem_ctx,
1197 union lsa_TrustedDomainInfo *info,
1198 enum lsa_TrustDomInfoEnum info_class,
1199 DATA_BLOB session_key)
1201 switch (info_class) {
1202 case LSA_TRUSTED_DOMAIN_INFO_PASSWORD:
1203 display_trust_dom_info_4(&info->password, session_key);
1204 break;
1205 default: {
1206 const char *str = NULL;
1207 str = NDR_PRINT_UNION_STRING(mem_ctx,
1208 lsa_TrustedDomainInfo,
1209 info_class, info);
1210 if (str) {
1211 d_printf("%s\n", str);
1213 break;
1218 static NTSTATUS cmd_lsa_query_trustdominfobysid(struct rpc_pipe_client *cli,
1219 TALLOC_CTX *mem_ctx, int argc,
1220 const char **argv)
1222 struct policy_handle pol;
1223 NTSTATUS status, result;
1224 struct dom_sid dom_sid;
1225 uint32 access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
1226 union lsa_TrustedDomainInfo *info = NULL;
1227 enum lsa_TrustDomInfoEnum info_class = 1;
1228 DATA_BLOB session_key;
1229 struct dcerpc_binding_handle *b = cli->binding_handle;
1231 if (argc > 3 || argc < 2) {
1232 printf("Usage: %s [sid] [info_class]\n", argv[0]);
1233 return NT_STATUS_OK;
1236 if (!string_to_sid(&dom_sid, argv[1]))
1237 return NT_STATUS_NO_MEMORY;
1239 if (argc == 3)
1240 info_class = atoi(argv[2]);
1242 status = rpccli_lsa_open_policy2(cli, mem_ctx, True, access_mask, &pol);
1244 if (!NT_STATUS_IS_OK(status))
1245 goto done;
1247 status = dcerpc_lsa_QueryTrustedDomainInfoBySid(b, mem_ctx,
1248 &pol,
1249 &dom_sid,
1250 info_class,
1251 &info,
1252 &result);
1253 if (!NT_STATUS_IS_OK(status))
1254 goto done;
1255 if (!NT_STATUS_IS_OK(result)) {
1256 status = result;
1257 goto done;
1260 status = cli_get_session_key(mem_ctx, cli, &session_key);
1261 if (!NT_STATUS_IS_OK(status)) {
1262 DEBUG(0, ("Could not retrieve session key: %s\n", nt_errstr(status)));
1263 goto done;
1266 display_trust_dom_info(mem_ctx, info, info_class, session_key);
1268 done:
1269 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
1271 return status;
1274 static NTSTATUS cmd_lsa_query_trustdominfobyname(struct rpc_pipe_client *cli,
1275 TALLOC_CTX *mem_ctx, int argc,
1276 const char **argv)
1278 struct policy_handle pol;
1279 NTSTATUS status, result;
1280 uint32 access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
1281 union lsa_TrustedDomainInfo *info = NULL;
1282 enum lsa_TrustDomInfoEnum info_class = 1;
1283 struct lsa_String trusted_domain;
1284 struct dcerpc_binding_handle *b = cli->binding_handle;
1285 DATA_BLOB session_key;
1287 if (argc > 3 || argc < 2) {
1288 printf("Usage: %s [name] [info_class]\n", argv[0]);
1289 return NT_STATUS_OK;
1292 if (argc == 3)
1293 info_class = atoi(argv[2]);
1295 status = rpccli_lsa_open_policy2(cli, mem_ctx, True, access_mask, &pol);
1297 if (!NT_STATUS_IS_OK(status))
1298 goto done;
1300 init_lsa_String(&trusted_domain, argv[1]);
1302 status = dcerpc_lsa_QueryTrustedDomainInfoByName(b, mem_ctx,
1303 &pol,
1304 &trusted_domain,
1305 info_class,
1306 &info,
1307 &result);
1308 if (!NT_STATUS_IS_OK(status))
1309 goto done;
1310 if (!NT_STATUS_IS_OK(result)) {
1311 status = result;
1312 goto done;
1315 status = cli_get_session_key(mem_ctx, cli, &session_key);
1316 if (!NT_STATUS_IS_OK(status)) {
1317 DEBUG(0, ("Could not retrieve session key: %s\n", nt_errstr(status)));
1318 goto done;
1321 display_trust_dom_info(mem_ctx, info, info_class, session_key);
1323 done:
1324 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
1326 return status;
1329 static NTSTATUS cmd_lsa_set_trustdominfo(struct rpc_pipe_client *cli,
1330 TALLOC_CTX *mem_ctx, int argc,
1331 const char **argv)
1333 struct policy_handle pol, trustdom_pol;
1334 NTSTATUS status, result;
1335 uint32 access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
1336 union lsa_TrustedDomainInfo info;
1337 struct dom_sid dom_sid;
1338 enum lsa_TrustDomInfoEnum info_class = 1;
1339 struct dcerpc_binding_handle *b = cli->binding_handle;
1341 if (argc > 4 || argc < 3) {
1342 printf("Usage: %s [sid] [info_class] [value]\n", argv[0]);
1343 return NT_STATUS_OK;
1346 if (!string_to_sid(&dom_sid, argv[1])) {
1347 return NT_STATUS_NO_MEMORY;
1351 info_class = atoi(argv[2]);
1353 switch (info_class) {
1354 case 13: /* LSA_TRUSTED_DOMAIN_SUPPORTED_ENCRYPTION_TYPES */
1355 info.enc_types.enc_types = atoi(argv[3]);
1356 break;
1357 default:
1358 return NT_STATUS_INVALID_PARAMETER;
1361 status = rpccli_lsa_open_policy2(cli, mem_ctx, True, access_mask, &pol);
1362 if (!NT_STATUS_IS_OK(status)) {
1363 goto done;
1366 status = dcerpc_lsa_OpenTrustedDomain(b, mem_ctx,
1367 &pol,
1368 &dom_sid,
1369 access_mask,
1370 &trustdom_pol,
1371 &result);
1372 if (!NT_STATUS_IS_OK(status)) {
1373 goto done;
1375 if (!NT_STATUS_IS_OK(result)) {
1376 status = result;
1377 goto done;
1380 status = dcerpc_lsa_SetInformationTrustedDomain(b, mem_ctx,
1381 &trustdom_pol,
1382 info_class,
1383 &info,
1384 &result);
1385 if (!NT_STATUS_IS_OK(status)) {
1386 goto done;
1388 if (!NT_STATUS_IS_OK(result)) {
1389 status = result;
1390 goto done;
1392 done:
1393 dcerpc_lsa_Close(b, mem_ctx, &trustdom_pol, &result);
1394 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
1396 return status;
1399 static NTSTATUS cmd_lsa_query_trustdominfo(struct rpc_pipe_client *cli,
1400 TALLOC_CTX *mem_ctx, int argc,
1401 const char **argv)
1403 struct policy_handle pol, trustdom_pol;
1404 NTSTATUS status, result;
1405 uint32 access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
1406 union lsa_TrustedDomainInfo *info = NULL;
1407 struct dom_sid dom_sid;
1408 enum lsa_TrustDomInfoEnum info_class = 1;
1409 DATA_BLOB session_key;
1410 struct dcerpc_binding_handle *b = cli->binding_handle;
1412 if (argc > 3 || argc < 2) {
1413 printf("Usage: %s [sid] [info_class]\n", argv[0]);
1414 return NT_STATUS_OK;
1417 if (!string_to_sid(&dom_sid, argv[1]))
1418 return NT_STATUS_NO_MEMORY;
1421 if (argc == 3)
1422 info_class = atoi(argv[2]);
1424 status = rpccli_lsa_open_policy2(cli, mem_ctx, True, access_mask, &pol);
1426 if (!NT_STATUS_IS_OK(status))
1427 goto done;
1429 status = dcerpc_lsa_OpenTrustedDomain(b, mem_ctx,
1430 &pol,
1431 &dom_sid,
1432 access_mask,
1433 &trustdom_pol,
1434 &result);
1435 if (!NT_STATUS_IS_OK(status))
1436 goto done;
1437 if (!NT_STATUS_IS_OK(result)) {
1438 status = result;
1439 goto done;
1442 status = dcerpc_lsa_QueryTrustedDomainInfo(b, mem_ctx,
1443 &trustdom_pol,
1444 info_class,
1445 &info,
1446 &result);
1447 if (!NT_STATUS_IS_OK(status))
1448 goto done;
1449 if (!NT_STATUS_IS_OK(result)) {
1450 status = result;
1451 goto done;
1454 status = cli_get_session_key(mem_ctx, cli, &session_key);
1455 if (!NT_STATUS_IS_OK(status)) {
1456 DEBUG(0, ("Could not retrieve session key: %s\n", nt_errstr(status)));
1457 goto done;
1460 display_trust_dom_info(mem_ctx, info, info_class, session_key);
1462 done:
1463 dcerpc_lsa_Close(b, mem_ctx, &pol, &result);
1465 return status;
1468 static NTSTATUS cmd_lsa_get_username(struct rpc_pipe_client *cli,
1469 TALLOC_CTX *mem_ctx, int argc,
1470 const char **argv)
1472 NTSTATUS status, result;
1473 const char *servername = cli->desthost;
1474 struct lsa_String *account_name = NULL;
1475 struct lsa_String *authority_name = NULL;
1476 struct dcerpc_binding_handle *b = cli->binding_handle;
1478 if (argc > 2) {
1479 printf("Usage: %s servername\n", argv[0]);
1480 return NT_STATUS_OK;
1483 status = dcerpc_lsa_GetUserName(b, mem_ctx,
1484 servername,
1485 &account_name,
1486 &authority_name,
1487 &result);
1488 if (!NT_STATUS_IS_OK(status)) {
1489 goto done;
1491 if (!NT_STATUS_IS_OK(result)) {
1492 status = result;
1493 goto done;
1496 /* Print results */
1498 printf("Account Name: %s, Authority Name: %s\n",
1499 account_name->string, authority_name ? authority_name->string :
1500 "");
1502 done:
1503 return status;
1506 static NTSTATUS cmd_lsa_add_priv(struct rpc_pipe_client *cli,
1507 TALLOC_CTX *mem_ctx, int argc,
1508 const char **argv)
1510 struct policy_handle dom_pol, user_pol;
1511 NTSTATUS status, result;
1512 struct lsa_PrivilegeSet privs;
1513 struct lsa_LUIDAttribute *set = NULL;
1514 struct dom_sid sid;
1515 int i;
1516 struct dcerpc_binding_handle *b = cli->binding_handle;
1518 ZERO_STRUCT(privs);
1520 if (argc < 3 ) {
1521 printf("Usage: %s SID [rights...]\n", argv[0]);
1522 return NT_STATUS_OK;
1525 status = name_to_sid(cli, mem_ctx, &sid, argv[1]);
1526 if (!NT_STATUS_IS_OK(status)) {
1527 goto done;
1530 status = rpccli_lsa_open_policy2(cli, mem_ctx, True,
1531 SEC_FLAG_MAXIMUM_ALLOWED,
1532 &dom_pol);
1534 if (!NT_STATUS_IS_OK(status)) {
1535 goto done;
1538 status = dcerpc_lsa_OpenAccount(b, mem_ctx,
1539 &dom_pol,
1540 &sid,
1541 SEC_FLAG_MAXIMUM_ALLOWED,
1542 &user_pol,
1543 &result);
1544 if (!NT_STATUS_IS_OK(status)) {
1545 goto done;
1547 if (!NT_STATUS_IS_OK(result)) {
1548 status = result;
1549 goto done;
1552 for (i=2; i<argc; i++) {
1554 struct lsa_String priv_name;
1555 struct lsa_LUID luid;
1557 init_lsa_String(&priv_name, argv[i]);
1559 status = dcerpc_lsa_LookupPrivValue(b, mem_ctx,
1560 &dom_pol,
1561 &priv_name,
1562 &luid,
1563 &result);
1564 if (!NT_STATUS_IS_OK(status)) {
1565 continue;
1567 if (!NT_STATUS_IS_OK(result)) {
1568 status = result;
1569 continue;
1572 privs.count++;
1573 set = talloc_realloc(mem_ctx, set,
1574 struct lsa_LUIDAttribute,
1575 privs.count);
1576 if (!set) {
1577 return NT_STATUS_NO_MEMORY;
1580 set[privs.count-1].luid = luid;
1581 set[privs.count-1].attribute = 0;
1584 privs.set = set;
1586 status = dcerpc_lsa_AddPrivilegesToAccount(b, mem_ctx,
1587 &user_pol,
1588 &privs,
1589 &result);
1590 if (!NT_STATUS_IS_OK(status)) {
1591 goto done;
1593 if (!NT_STATUS_IS_OK(result)) {
1594 status = result;
1595 goto done;
1598 dcerpc_lsa_Close(b, mem_ctx, &user_pol, &result);
1599 dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result);
1600 done:
1601 return status;
1604 static NTSTATUS cmd_lsa_del_priv(struct rpc_pipe_client *cli,
1605 TALLOC_CTX *mem_ctx, int argc,
1606 const char **argv)
1608 struct policy_handle dom_pol, user_pol;
1609 NTSTATUS status, result;
1610 struct lsa_PrivilegeSet privs;
1611 struct lsa_LUIDAttribute *set = NULL;
1612 struct dom_sid sid;
1613 int i;
1614 struct dcerpc_binding_handle *b = cli->binding_handle;
1616 ZERO_STRUCT(privs);
1618 if (argc < 3 ) {
1619 printf("Usage: %s SID [rights...]\n", argv[0]);
1620 return NT_STATUS_OK;
1623 status = name_to_sid(cli, mem_ctx, &sid, argv[1]);
1624 if (!NT_STATUS_IS_OK(status)) {
1625 goto done;
1628 status = rpccli_lsa_open_policy2(cli, mem_ctx, True,
1629 SEC_FLAG_MAXIMUM_ALLOWED,
1630 &dom_pol);
1632 if (!NT_STATUS_IS_OK(status)) {
1633 goto done;
1636 status = dcerpc_lsa_OpenAccount(b, mem_ctx,
1637 &dom_pol,
1638 &sid,
1639 SEC_FLAG_MAXIMUM_ALLOWED,
1640 &user_pol,
1641 &result);
1642 if (!NT_STATUS_IS_OK(status)) {
1643 goto done;
1645 if (!NT_STATUS_IS_OK(result)) {
1646 status = result;
1647 goto done;
1650 for (i=2; i<argc; i++) {
1652 struct lsa_String priv_name;
1653 struct lsa_LUID luid;
1655 init_lsa_String(&priv_name, argv[i]);
1657 status = dcerpc_lsa_LookupPrivValue(b, mem_ctx,
1658 &dom_pol,
1659 &priv_name,
1660 &luid,
1661 &result);
1662 if (!NT_STATUS_IS_OK(status)) {
1663 continue;
1665 if (!NT_STATUS_IS_OK(result)) {
1666 status = result;
1667 continue;
1670 privs.count++;
1671 set = talloc_realloc(mem_ctx, set,
1672 struct lsa_LUIDAttribute,
1673 privs.count);
1674 if (!set) {
1675 return NT_STATUS_NO_MEMORY;
1678 set[privs.count-1].luid = luid;
1679 set[privs.count-1].attribute = 0;
1682 privs.set = set;
1685 status = dcerpc_lsa_RemovePrivilegesFromAccount(b, mem_ctx,
1686 &user_pol,
1687 false,
1688 &privs,
1689 &result);
1690 if (!NT_STATUS_IS_OK(status)) {
1691 goto done;
1693 if (!NT_STATUS_IS_OK(result)) {
1694 status = result;
1695 goto done;
1698 dcerpc_lsa_Close(b, mem_ctx, &user_pol, &result);
1699 dcerpc_lsa_Close(b, mem_ctx, &dom_pol, &result);
1700 done:
1701 return status;
1704 static NTSTATUS cmd_lsa_create_secret(struct rpc_pipe_client *cli,
1705 TALLOC_CTX *mem_ctx, int argc,
1706 const char **argv)
1708 NTSTATUS status, result;
1709 struct policy_handle handle, sec_handle;
1710 struct lsa_String name;
1711 struct dcerpc_binding_handle *b = cli->binding_handle;
1713 if (argc < 2) {
1714 printf("Usage: %s name\n", argv[0]);
1715 return NT_STATUS_OK;
1718 status = rpccli_lsa_open_policy2(cli, mem_ctx,
1719 true,
1720 SEC_FLAG_MAXIMUM_ALLOWED,
1721 &handle);
1722 if (!NT_STATUS_IS_OK(status)) {
1723 return status;
1726 init_lsa_String(&name, argv[1]);
1728 status = dcerpc_lsa_CreateSecret(b, mem_ctx,
1729 &handle,
1730 name,
1731 SEC_FLAG_MAXIMUM_ALLOWED,
1732 &sec_handle,
1733 &result);
1734 if (!NT_STATUS_IS_OK(status)) {
1735 goto done;
1737 if (!NT_STATUS_IS_OK(result)) {
1738 status = result;
1739 goto done;
1742 done:
1743 if (is_valid_policy_hnd(&sec_handle)) {
1744 dcerpc_lsa_Close(b, mem_ctx, &sec_handle, &result);
1746 if (is_valid_policy_hnd(&handle)) {
1747 dcerpc_lsa_Close(b, mem_ctx, &handle, &result);
1750 return status;
1753 static NTSTATUS cmd_lsa_delete_secret(struct rpc_pipe_client *cli,
1754 TALLOC_CTX *mem_ctx, int argc,
1755 const char **argv)
1757 NTSTATUS status, result;
1758 struct policy_handle handle, sec_handle;
1759 struct lsa_String name;
1760 struct dcerpc_binding_handle *b = cli->binding_handle;
1762 if (argc < 2) {
1763 printf("Usage: %s name\n", argv[0]);
1764 return NT_STATUS_OK;
1767 status = rpccli_lsa_open_policy2(cli, mem_ctx,
1768 true,
1769 SEC_FLAG_MAXIMUM_ALLOWED,
1770 &handle);
1771 if (!NT_STATUS_IS_OK(status)) {
1772 return status;
1775 init_lsa_String(&name, argv[1]);
1777 status = dcerpc_lsa_OpenSecret(b, mem_ctx,
1778 &handle,
1779 name,
1780 SEC_FLAG_MAXIMUM_ALLOWED,
1781 &sec_handle,
1782 &result);
1783 if (!NT_STATUS_IS_OK(status)) {
1784 goto done;
1786 if (!NT_STATUS_IS_OK(result)) {
1787 status = result;
1788 goto done;
1791 status = dcerpc_lsa_DeleteObject(b, mem_ctx,
1792 &sec_handle,
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 done:
1803 if (is_valid_policy_hnd(&sec_handle)) {
1804 dcerpc_lsa_Close(b, mem_ctx, &sec_handle, &result);
1806 if (is_valid_policy_hnd(&handle)) {
1807 dcerpc_lsa_Close(b, mem_ctx, &handle, &result);
1810 return status;
1813 static NTSTATUS cmd_lsa_query_secret(struct rpc_pipe_client *cli,
1814 TALLOC_CTX *mem_ctx, int argc,
1815 const char **argv)
1817 NTSTATUS status, result;
1818 struct policy_handle handle, sec_handle;
1819 struct lsa_String name;
1820 struct lsa_DATA_BUF_PTR new_val;
1821 NTTIME new_mtime = 0;
1822 struct lsa_DATA_BUF_PTR old_val;
1823 NTTIME old_mtime = 0;
1824 DATA_BLOB session_key;
1825 DATA_BLOB new_blob = data_blob_null;
1826 DATA_BLOB old_blob = data_blob_null;
1827 char *new_secret, *old_secret;
1828 struct dcerpc_binding_handle *b = cli->binding_handle;
1830 if (argc < 2) {
1831 printf("Usage: %s name\n", argv[0]);
1832 return NT_STATUS_OK;
1835 status = rpccli_lsa_open_policy2(cli, mem_ctx,
1836 true,
1837 SEC_FLAG_MAXIMUM_ALLOWED,
1838 &handle);
1839 if (!NT_STATUS_IS_OK(status)) {
1840 return status;
1843 init_lsa_String(&name, argv[1]);
1845 status = dcerpc_lsa_OpenSecret(b, mem_ctx,
1846 &handle,
1847 name,
1848 SEC_FLAG_MAXIMUM_ALLOWED,
1849 &sec_handle,
1850 &result);
1851 if (!NT_STATUS_IS_OK(status)) {
1852 goto done;
1854 if (!NT_STATUS_IS_OK(result)) {
1855 status = result;
1856 goto done;
1859 ZERO_STRUCT(new_val);
1860 ZERO_STRUCT(old_val);
1862 status = dcerpc_lsa_QuerySecret(b, mem_ctx,
1863 &sec_handle,
1864 &new_val,
1865 &new_mtime,
1866 &old_val,
1867 &old_mtime,
1868 &result);
1869 if (!NT_STATUS_IS_OK(status)) {
1870 goto done;
1872 if (!NT_STATUS_IS_OK(result)) {
1873 status = result;
1874 goto done;
1877 status = cli_get_session_key(mem_ctx, cli, &session_key);
1878 if (!NT_STATUS_IS_OK(status)) {
1879 goto done;
1882 if (new_val.buf) {
1883 new_blob = data_blob_const(new_val.buf->data, new_val.buf->length);
1885 if (old_val.buf) {
1886 old_blob = data_blob_const(old_val.buf->data, old_val.buf->length);
1889 new_secret = sess_decrypt_string(mem_ctx, &new_blob, &session_key);
1890 old_secret = sess_decrypt_string(mem_ctx, &old_blob, &session_key);
1891 if (new_secret) {
1892 d_printf("new secret: %s\n", new_secret);
1894 if (old_secret) {
1895 d_printf("old secret: %s\n", old_secret);
1898 done:
1899 if (is_valid_policy_hnd(&sec_handle)) {
1900 dcerpc_lsa_Close(b, mem_ctx, &sec_handle, &result);
1902 if (is_valid_policy_hnd(&handle)) {
1903 dcerpc_lsa_Close(b, mem_ctx, &handle, &result);
1906 return status;
1909 static NTSTATUS cmd_lsa_set_secret(struct rpc_pipe_client *cli,
1910 TALLOC_CTX *mem_ctx, int argc,
1911 const char **argv)
1913 NTSTATUS status, result;
1914 struct policy_handle handle, sec_handle;
1915 struct lsa_String name;
1916 struct lsa_DATA_BUF new_val;
1917 struct lsa_DATA_BUF old_val;
1918 DATA_BLOB enc_key;
1919 DATA_BLOB session_key;
1920 struct dcerpc_binding_handle *b = cli->binding_handle;
1922 if (argc < 3) {
1923 printf("Usage: %s name secret\n", argv[0]);
1924 return NT_STATUS_OK;
1927 status = rpccli_lsa_open_policy2(cli, mem_ctx,
1928 true,
1929 SEC_FLAG_MAXIMUM_ALLOWED,
1930 &handle);
1931 if (!NT_STATUS_IS_OK(status)) {
1932 return status;
1935 init_lsa_String(&name, argv[1]);
1937 status = dcerpc_lsa_OpenSecret(b, mem_ctx,
1938 &handle,
1939 name,
1940 SEC_FLAG_MAXIMUM_ALLOWED,
1941 &sec_handle,
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 ZERO_STRUCT(new_val);
1952 ZERO_STRUCT(old_val);
1954 status = cli_get_session_key(mem_ctx, cli, &session_key);
1955 if (!NT_STATUS_IS_OK(status)) {
1956 goto done;
1959 enc_key = sess_encrypt_string(argv[2], &session_key);
1961 new_val.length = enc_key.length;
1962 new_val.size = enc_key.length;
1963 new_val.data = enc_key.data;
1965 status = dcerpc_lsa_SetSecret(b, mem_ctx,
1966 &sec_handle,
1967 &new_val,
1968 NULL,
1969 &result);
1970 if (!NT_STATUS_IS_OK(status)) {
1971 goto done;
1973 if (!NT_STATUS_IS_OK(result)) {
1974 status = result;
1975 goto done;
1978 done:
1979 if (is_valid_policy_hnd(&sec_handle)) {
1980 dcerpc_lsa_Close(b, mem_ctx, &sec_handle, &result);
1982 if (is_valid_policy_hnd(&handle)) {
1983 dcerpc_lsa_Close(b, mem_ctx, &handle, &result);
1986 return status;
1989 static NTSTATUS cmd_lsa_retrieve_private_data(struct rpc_pipe_client *cli,
1990 TALLOC_CTX *mem_ctx, int argc,
1991 const char **argv)
1993 NTSTATUS status, result;
1994 struct policy_handle handle;
1995 struct lsa_String name;
1996 struct lsa_DATA_BUF *val;
1997 DATA_BLOB session_key;
1998 DATA_BLOB blob = data_blob_null;
1999 char *secret;
2000 struct dcerpc_binding_handle *b = cli->binding_handle;
2002 if (argc < 2) {
2003 printf("Usage: %s name\n", argv[0]);
2004 return NT_STATUS_OK;
2007 status = rpccli_lsa_open_policy2(cli, mem_ctx,
2008 true,
2009 SEC_FLAG_MAXIMUM_ALLOWED,
2010 &handle);
2011 if (!NT_STATUS_IS_OK(status)) {
2012 return status;
2015 init_lsa_String(&name, argv[1]);
2017 ZERO_STRUCT(val);
2019 status = dcerpc_lsa_RetrievePrivateData(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 status = cli_get_session_key(mem_ctx, cli, &session_key);
2033 if (!NT_STATUS_IS_OK(status)) {
2034 goto done;
2037 if (val) {
2038 blob = data_blob_const(val->data, val->length);
2041 secret = sess_decrypt_string(mem_ctx, &blob, &session_key);
2042 if (secret) {
2043 d_printf("secret: %s\n", secret);
2046 done:
2047 if (is_valid_policy_hnd(&handle)) {
2048 dcerpc_lsa_Close(b, mem_ctx, &handle, &result);
2051 return status;
2054 static NTSTATUS cmd_lsa_store_private_data(struct rpc_pipe_client *cli,
2055 TALLOC_CTX *mem_ctx, int argc,
2056 const char **argv)
2058 NTSTATUS status, result;
2059 struct policy_handle handle;
2060 struct lsa_String name;
2061 struct lsa_DATA_BUF val;
2062 DATA_BLOB session_key;
2063 DATA_BLOB enc_key;
2064 struct dcerpc_binding_handle *b = cli->binding_handle;
2066 if (argc < 3) {
2067 printf("Usage: %s name secret\n", argv[0]);
2068 return NT_STATUS_OK;
2071 status = rpccli_lsa_open_policy2(cli, mem_ctx,
2072 true,
2073 SEC_FLAG_MAXIMUM_ALLOWED,
2074 &handle);
2075 if (!NT_STATUS_IS_OK(status)) {
2076 return status;
2079 init_lsa_String(&name, argv[1]);
2081 ZERO_STRUCT(val);
2083 status = cli_get_session_key(mem_ctx, cli, &session_key);
2084 if (!NT_STATUS_IS_OK(status)) {
2085 goto done;
2088 enc_key = sess_encrypt_string(argv[2], &session_key);
2090 val.length = enc_key.length;
2091 val.size = enc_key.length;
2092 val.data = enc_key.data;
2094 status = dcerpc_lsa_StorePrivateData(b, mem_ctx,
2095 &handle,
2096 &name,
2097 &val,
2098 &result);
2099 if (!NT_STATUS_IS_OK(status)) {
2100 goto done;
2102 if (!NT_STATUS_IS_OK(result)) {
2103 status = result;
2104 goto done;
2107 done:
2108 if (is_valid_policy_hnd(&handle)) {
2109 dcerpc_lsa_Close(b, mem_ctx, &handle, &result);
2112 return status;
2115 static NTSTATUS cmd_lsa_create_trusted_domain(struct rpc_pipe_client *cli,
2116 TALLOC_CTX *mem_ctx, int argc,
2117 const char **argv)
2119 NTSTATUS status, result;
2120 struct policy_handle handle, trustdom_handle;
2121 struct dom_sid sid;
2122 struct lsa_DomainInfo info;
2123 struct dcerpc_binding_handle *b = cli->binding_handle;
2125 if (argc < 3) {
2126 printf("Usage: %s name sid\n", argv[0]);
2127 return NT_STATUS_OK;
2130 status = rpccli_lsa_open_policy2(cli, mem_ctx,
2131 true,
2132 SEC_FLAG_MAXIMUM_ALLOWED,
2133 &handle);
2134 if (!NT_STATUS_IS_OK(status)) {
2135 return status;
2138 init_lsa_StringLarge(&info.name, argv[1]);
2139 info.sid = &sid;
2140 string_to_sid(&sid, argv[2]);
2142 status = dcerpc_lsa_CreateTrustedDomain(b, mem_ctx,
2143 &handle,
2144 &info,
2145 SEC_FLAG_MAXIMUM_ALLOWED,
2146 &trustdom_handle,
2147 &result);
2148 if (!NT_STATUS_IS_OK(status)) {
2149 goto done;
2151 if (!NT_STATUS_IS_OK(result)) {
2152 status = result;
2153 goto done;
2156 done:
2157 if (is_valid_policy_hnd(&trustdom_handle)) {
2158 dcerpc_lsa_Close(b, mem_ctx, &trustdom_handle, &result);
2161 if (is_valid_policy_hnd(&handle)) {
2162 dcerpc_lsa_Close(b, mem_ctx, &handle, &result);
2165 return status;
2168 static NTSTATUS cmd_lsa_delete_trusted_domain(struct rpc_pipe_client *cli,
2169 TALLOC_CTX *mem_ctx, int argc,
2170 const char **argv)
2172 NTSTATUS status, result;
2173 struct policy_handle handle, trustdom_handle;
2174 struct lsa_String name;
2175 struct dom_sid *sid = NULL;
2176 struct dcerpc_binding_handle *b = cli->binding_handle;
2178 if (argc < 2) {
2179 printf("Usage: %s name\n", argv[0]);
2180 return NT_STATUS_OK;
2183 status = rpccli_lsa_open_policy2(cli, mem_ctx,
2184 true,
2185 SEC_FLAG_MAXIMUM_ALLOWED,
2186 &handle);
2187 if (!NT_STATUS_IS_OK(status)) {
2188 return status;
2191 init_lsa_String(&name, argv[1]);
2193 status = dcerpc_lsa_OpenTrustedDomainByName(b, mem_ctx,
2194 &handle,
2195 name,
2196 SEC_FLAG_MAXIMUM_ALLOWED,
2197 &trustdom_handle,
2198 &result);
2199 if (NT_STATUS_IS_OK(status) && NT_STATUS_IS_OK(result)) {
2200 goto delete_object;
2204 uint32_t resume_handle = 0;
2205 struct lsa_DomainList domains;
2206 int i;
2208 status = dcerpc_lsa_EnumTrustDom(b, mem_ctx,
2209 &handle,
2210 &resume_handle,
2211 &domains,
2212 0xffff,
2213 &result);
2214 if (!NT_STATUS_IS_OK(status)) {
2215 goto done;
2217 if (!NT_STATUS_IS_OK(result)) {
2218 status = result;
2219 goto done;
2222 for (i=0; i < domains.count; i++) {
2223 if (strequal(domains.domains[i].name.string, argv[1])) {
2224 sid = domains.domains[i].sid;
2225 break;
2229 if (!sid) {
2230 return NT_STATUS_INVALID_SID;
2234 status = dcerpc_lsa_OpenTrustedDomain(b, mem_ctx,
2235 &handle,
2236 sid,
2237 SEC_FLAG_MAXIMUM_ALLOWED,
2238 &trustdom_handle,
2239 &result);
2240 if (!NT_STATUS_IS_OK(status)) {
2241 goto done;
2243 if (!NT_STATUS_IS_OK(result)) {
2244 status = result;
2245 goto done;
2248 delete_object:
2249 status = dcerpc_lsa_DeleteObject(b, mem_ctx,
2250 &trustdom_handle,
2251 &result);
2252 if (!NT_STATUS_IS_OK(status)) {
2253 goto done;
2255 if (!NT_STATUS_IS_OK(result)) {
2256 status = result;
2257 goto done;
2260 done:
2261 if (is_valid_policy_hnd(&trustdom_handle)) {
2262 dcerpc_lsa_Close(b, mem_ctx, &trustdom_handle, &result);
2265 if (is_valid_policy_hnd(&handle)) {
2266 dcerpc_lsa_Close(b, mem_ctx, &handle, &result);
2269 return status;
2273 /* List of commands exported by this module */
2275 struct cmd_set lsarpc_commands[] = {
2277 { "LSARPC" },
2279 { "lsaquery", RPC_RTYPE_NTSTATUS, cmd_lsa_query_info_policy, NULL, &ndr_table_lsarpc, NULL, "Query info policy", "" },
2280 { "lookupsids", RPC_RTYPE_NTSTATUS, cmd_lsa_lookup_sids, NULL, &ndr_table_lsarpc, NULL, "Convert SIDs to names", "" },
2281 { "lookupsids3", RPC_RTYPE_NTSTATUS, cmd_lsa_lookup_sids3, NULL, &ndr_table_lsarpc, NULL, "Convert SIDs to names", "" },
2282 { "lookupnames", RPC_RTYPE_NTSTATUS, cmd_lsa_lookup_names, NULL, &ndr_table_lsarpc, NULL, "Convert names to SIDs", "" },
2283 { "lookupnames4", RPC_RTYPE_NTSTATUS, cmd_lsa_lookup_names4, NULL, &ndr_table_lsarpc, NULL, "Convert names to SIDs", "" },
2284 { "lookupnames_level", RPC_RTYPE_NTSTATUS, cmd_lsa_lookup_names_level, NULL, &ndr_table_lsarpc, NULL, "Convert names to SIDs", "" },
2285 { "enumtrust", RPC_RTYPE_NTSTATUS, cmd_lsa_enum_trust_dom, NULL, &ndr_table_lsarpc, NULL, "Enumerate trusted domains", "Usage: [preferred max number] [enum context (0)]" },
2286 { "enumprivs", RPC_RTYPE_NTSTATUS, cmd_lsa_enum_privilege, NULL, &ndr_table_lsarpc, NULL, "Enumerate privileges", "" },
2287 { "getdispname", RPC_RTYPE_NTSTATUS, cmd_lsa_get_dispname, NULL, &ndr_table_lsarpc, NULL, "Get the privilege name", "" },
2288 { "lsaenumsid", RPC_RTYPE_NTSTATUS, cmd_lsa_enum_sids, NULL, &ndr_table_lsarpc, NULL, "Enumerate the LSA SIDS", "" },
2289 { "lsacreateaccount", RPC_RTYPE_NTSTATUS, cmd_lsa_create_account, NULL, &ndr_table_lsarpc, NULL, "Create a new lsa account", "" },
2290 { "lsaenumprivsaccount", RPC_RTYPE_NTSTATUS, cmd_lsa_enum_privsaccounts, NULL, &ndr_table_lsarpc, NULL, "Enumerate the privileges of an SID", "" },
2291 { "lsaenumacctrights", RPC_RTYPE_NTSTATUS, cmd_lsa_enum_acct_rights, NULL, &ndr_table_lsarpc, NULL, "Enumerate the rights of an SID", "" },
2292 { "lsaaddpriv", RPC_RTYPE_NTSTATUS, cmd_lsa_add_priv, NULL, &ndr_table_lsarpc, NULL, "Assign a privilege to a SID", "" },
2293 { "lsadelpriv", RPC_RTYPE_NTSTATUS, cmd_lsa_del_priv, NULL, &ndr_table_lsarpc, NULL, "Revoke a privilege from a SID", "" },
2294 { "lsaaddacctrights", RPC_RTYPE_NTSTATUS, cmd_lsa_add_acct_rights, NULL, &ndr_table_lsarpc, NULL, "Add rights to an account", "" },
2295 { "lsaremoveacctrights", RPC_RTYPE_NTSTATUS, cmd_lsa_remove_acct_rights, NULL, &ndr_table_lsarpc, NULL, "Remove rights from an account", "" },
2296 { "lsalookupprivvalue", RPC_RTYPE_NTSTATUS, cmd_lsa_lookup_priv_value, NULL, &ndr_table_lsarpc, NULL, "Get a privilege value given its name", "" },
2297 { "lsaquerysecobj", RPC_RTYPE_NTSTATUS, cmd_lsa_query_secobj, NULL, &ndr_table_lsarpc, NULL, "Query LSA security object", "" },
2298 { "lsaquerytrustdominfo",RPC_RTYPE_NTSTATUS, cmd_lsa_query_trustdominfo, NULL, &ndr_table_lsarpc, NULL, "Query LSA trusted domains info (given a SID)", "" },
2299 { "lsaquerytrustdominfobyname",RPC_RTYPE_NTSTATUS, cmd_lsa_query_trustdominfobyname, NULL, &ndr_table_lsarpc, NULL, "Query LSA trusted domains info (given a name), only works for Windows > 2k", "" },
2300 { "lsaquerytrustdominfobysid",RPC_RTYPE_NTSTATUS, cmd_lsa_query_trustdominfobysid, NULL, &ndr_table_lsarpc, NULL, "Query LSA trusted domains info (given a SID)", "" },
2301 { "lsasettrustdominfo", RPC_RTYPE_NTSTATUS, cmd_lsa_set_trustdominfo, NULL, &ndr_table_lsarpc, NULL, "Set LSA trusted domain info", "" },
2302 { "getusername", RPC_RTYPE_NTSTATUS, cmd_lsa_get_username, NULL, &ndr_table_lsarpc, NULL, "Get username", "" },
2303 { "createsecret", RPC_RTYPE_NTSTATUS, cmd_lsa_create_secret, NULL, &ndr_table_lsarpc, NULL, "Create Secret", "" },
2304 { "deletesecret", RPC_RTYPE_NTSTATUS, cmd_lsa_delete_secret, NULL, &ndr_table_lsarpc, NULL, "Delete Secret", "" },
2305 { "querysecret", RPC_RTYPE_NTSTATUS, cmd_lsa_query_secret, NULL, &ndr_table_lsarpc, NULL, "Query Secret", "" },
2306 { "setsecret", RPC_RTYPE_NTSTATUS, cmd_lsa_set_secret, NULL, &ndr_table_lsarpc, NULL, "Set Secret", "" },
2307 { "retrieveprivatedata", RPC_RTYPE_NTSTATUS, cmd_lsa_retrieve_private_data, NULL, &ndr_table_lsarpc, NULL, "Retrieve Private Data", "" },
2308 { "storeprivatedata", RPC_RTYPE_NTSTATUS, cmd_lsa_store_private_data, NULL, &ndr_table_lsarpc, NULL, "Store Private Data", "" },
2309 { "createtrustdom", RPC_RTYPE_NTSTATUS, cmd_lsa_create_trusted_domain, NULL, &ndr_table_lsarpc, NULL, "Create Trusted Domain", "" },
2310 { "deletetrustdom", RPC_RTYPE_NTSTATUS, cmd_lsa_delete_trusted_domain, NULL, &ndr_table_lsarpc, NULL, "Delete Trusted Domain", "" },
2312 { NULL }