2 Unix SMB/CIFS implementation.
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/>.
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
,
39 struct policy_handle pol
;
40 enum lsa_SidType
*sid_types
;
41 NTSTATUS status
, result
;
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
)) {
51 status
= rpccli_lsa_open_policy(cli
, mem_ctx
, True
,
52 SEC_FLAG_MAXIMUM_ALLOWED
,
54 if (!NT_STATUS_IS_OK(status
))
57 status
= rpccli_lsa_lookup_names(cli
, mem_ctx
, &pol
, 1, &name
, NULL
, 1, &sids
, &sid_types
);
58 if (!NT_STATUS_IS_OK(status
))
61 dcerpc_lsa_Close(b
, mem_ctx
, &pol
, &result
);
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
)
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(),
128 static void display_lsa_query_info(union lsa_PolicyInformation
*info
,
129 enum lsa_PolicyInfo level
)
133 display_query_info_1(&info
->audit_log
);
136 display_query_info_2(&info
->audit_events
);
139 display_query_info_3(&info
->domain
);
142 display_query_info_5(&info
->account_domain
);
145 display_query_info_10(&info
->auditfullset
);
148 display_query_info_11(&info
->auditfullquery
);
151 display_query_info_12(&info
->dns
);
154 printf("can't display info level: %d\n", level
);
159 static NTSTATUS
cmd_lsa_query_info_policy(struct rpc_pipe_client
*cli
,
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;
172 printf("Usage: %s [info_class]\n", argv
[0]);
177 info_class
= atoi(argv
[1]);
179 switch (info_class
) {
181 union lsa_revision_info out_revision_info
= {
186 uint32_t out_version
= 0;
188 status
= dcerpc_lsa_open_policy_fallback(
193 SEC_FLAG_MAXIMUM_ALLOWED
,
198 if (any_nt_status_not_ok(status
, result
, &status
)) {
202 status
= dcerpc_lsa_QueryInfoPolicy2(b
, mem_ctx
,
210 status
= rpccli_lsa_open_policy(cli
, mem_ctx
, True
,
211 SEC_FLAG_MAXIMUM_ALLOWED
,
214 if (!NT_STATUS_IS_OK(status
))
217 status
= dcerpc_lsa_QueryInfoPolicy(b
, mem_ctx
,
224 if (!NT_STATUS_IS_OK(status
)) {
228 if (NT_STATUS_IS_OK(result
)) {
229 display_lsa_query_info(info
, info_class
);
232 dcerpc_lsa_Close(b
, mem_ctx
, &pol
, &result
);
238 /* Resolve a list of names to a list of sids */
240 static NTSTATUS
cmd_lsa_lookup_names(struct rpc_pipe_client
*cli
,
245 struct policy_handle pol
;
246 NTSTATUS status
, result
;
247 struct dom_sid
*sids
;
248 enum lsa_SidType
*types
;
250 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
253 printf("Usage: %s [name1 [name2 [...]]]\n", argv
[0]);
257 status
= rpccli_lsa_open_policy(cli
, mem_ctx
, True
,
258 LSA_POLICY_LOOKUP_NAMES
,
261 if (!NT_STATUS_IS_OK(status
))
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
))
271 status
= NT_STATUS_OK
;
275 for (i
= 0; i
< (argc
- 1); i
++) {
276 struct dom_sid_buf sid_str
;
277 printf("%s %s (%s: %d)\n",
279 dom_sid_str_buf(&sids
[i
], &sid_str
),
280 sid_type_lookup(types
[i
]),
284 dcerpc_lsa_Close(b
, mem_ctx
, &pol
, &result
);
290 /* Resolve a list of names to a list of sids */
292 static NTSTATUS
cmd_lsa_lookup_names_level(struct rpc_pipe_client
*cli
,
297 struct policy_handle pol
;
298 NTSTATUS status
, result
;
299 struct dom_sid
*sids
= NULL
;
300 enum lsa_SidType
*types
= NULL
;
302 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
305 printf("Usage: %s [level] [name1 [name2 [...]]]\n", argv
[0]);
309 status
= rpccli_lsa_open_policy(cli
, mem_ctx
, True
,
310 LSA_POLICY_LOOKUP_NAMES
,
312 if (!NT_STATUS_IS_OK(status
)) {
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
))
327 status
= NT_STATUS_OK
;
331 for (i
= 0; i
< (argc
- 2); i
++) {
332 struct dom_sid_buf sid_str
;
333 printf("%s %s (%s: %d)\n",
335 dom_sid_str_buf(&sids
[i
], &sid_str
),
336 sid_type_lookup(types
[i
]),
340 dcerpc_lsa_Close(b
, mem_ctx
, &pol
, &result
);
346 static NTSTATUS
cmd_lsa_lookup_names4(struct rpc_pipe_client
*cli
,
347 TALLOC_CTX
*mem_ctx
, int argc
,
350 NTSTATUS status
, result
;
353 struct lsa_String
*names
;
354 struct lsa_RefDomainList
*domains
= NULL
;
355 struct lsa_TransSidArray3 sids
;
358 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
361 printf("Usage: %s [name1 [name2 [...]]]\n", argv
[0]);
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
,
385 if (!NT_STATUS_IS_OK(status
)) {
388 if (!NT_STATUS_IS_OK(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",
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
);
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
;
418 enum lsa_SidType
*types
;
420 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
423 printf("Usage: %s [sid1 [sid2 [...]]]\n", argv
[0]);
427 status
= rpccli_lsa_open_policy(cli
, mem_ctx
, True
,
428 LSA_POLICY_LOOKUP_NAMES
,
431 if (!NT_STATUS_IS_OK(status
))
434 /* Convert arguments to sids */
436 sids
= talloc_array(mem_ctx
, struct dom_sid
, argc
- 1);
439 printf("could not allocate memory for %d sids\n", argc
- 1);
443 for (i
= 0; i
< argc
- 1; i
++)
444 if (!string_to_sid(&sids
[i
], argv
[i
+ 1])) {
445 status
= NT_STATUS_INVALID_SID
;
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
))
458 status
= NT_STATUS_OK
;
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*",
471 printf("%s %s\\%s (%d)\n", sid_str
.buf
,
472 domains
[i
] ? domains
[i
] : "*unknown*",
473 names
[i
] ? names
[i
] : "*unknown*",
478 dcerpc_lsa_Close(b
, mem_ctx
, &pol
, &result
);
484 static NTSTATUS
cmd_lsa_lookup_sids_level(struct rpc_pipe_client
*cli
,
485 TALLOC_CTX
*mem_ctx
, int argc
,
488 struct policy_handle pol
;
489 NTSTATUS status
, result
;
490 struct dom_sid
*sids
= NULL
;
491 char **domains
= NULL
;
493 enum lsa_SidType
*types
= NULL
;
495 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
498 printf("Usage: %s [level] [sid1 [sid2 [...]]]\n", argv
[0]);
502 status
= rpccli_lsa_open_policy(cli
, mem_ctx
, True
,
503 LSA_POLICY_LOOKUP_NAMES
,
505 if (!NT_STATUS_IS_OK(status
)) {
509 level
= atoi(argv
[1]);
511 /* Convert arguments to sids */
513 sids
= talloc_array(mem_ctx
, struct dom_sid
, argc
- 2);
515 printf("could not allocate memory for %d sids\n", argc
- 2);
519 for (i
= 0; i
< argc
- 2; i
++) {
520 if (!string_to_sid(&sids
[i
], argv
[i
+ 2])) {
521 status
= NT_STATUS_INVALID_SID
;
526 /* Lookup the SIDs */
528 status
= dcerpc_lsa_lookup_sids_generic(cli
->binding_handle
,
539 if (!NT_STATUS_IS_OK(status
)) {
544 if (!NT_STATUS_IS_OK(status
) && NT_STATUS_V(status
) !=
545 NT_STATUS_V(STATUS_SOME_UNMAPPED
))
550 status
= NT_STATUS_OK
;
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*",
563 printf("%s %s\\%s (%d)\n", sid_str
.buf
,
564 domains
[i
] ? domains
[i
] : "*unknown*",
565 names
[i
] ? names
[i
] : "*unknown*",
570 dcerpc_lsa_Close(b
, mem_ctx
, &pol
, &result
);
576 /* Resolve a list of SIDs to a list of names */
578 static NTSTATUS
cmd_lsa_lookup_sids3(struct rpc_pipe_client
*cli
,
580 int argc
, const char **argv
)
582 NTSTATUS status
= NT_STATUS_UNSUCCESSFUL
, result
;
584 struct lsa_SidArray sids
;
585 struct lsa_RefDomainList
*domains
= NULL
;
586 struct lsa_TransNameArray2 names
;
588 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
591 printf("Usage: %s [sid1 [sid2 [...]]]\n", argv
[0]);
597 /* Convert arguments to sids */
599 sids
.num_sids
= argc
-1;
600 sids
.sids
= talloc_array(mem_ctx
, struct lsa_SidPtr
, sids
.num_sids
);
602 printf("could not allocate memory for %d sids\n", sids
.num_sids
);
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
;
612 if (!string_to_sid(sids
.sids
[i
].sid
, argv
[i
+1])) {
613 status
= NT_STATUS_INVALID_SID
;
618 /* Lookup the SIDs */
619 status
= dcerpc_lsa_LookupSids3(b
, mem_ctx
,
628 if (!NT_STATUS_IS_OK(status
)) {
631 if (!NT_STATUS_IS_OK(result
) && NT_STATUS_V(result
) !=
632 NT_STATUS_V(STATUS_SOME_UNMAPPED
)) {
637 status
= NT_STATUS_OK
;
641 for (i
= 0; i
< names
.count
; i
++) {
642 struct dom_sid_buf sid_str
;
644 if (i
>= sids
.num_sids
) {
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
);
658 /* Enumerate list of trusted domains */
660 static NTSTATUS
cmd_lsa_enum_trust_dom(struct rpc_pipe_client
*cli
,
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;
673 uint32_t max_size
= (uint32_t)-1;
676 printf("Usage: %s [enum context (0)]\n", argv
[0]);
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
,
688 if (!NT_STATUS_IS_OK(status
))
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
,
703 if (!NT_STATUS_IS_OK(status
)) {
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
)) {
713 /* Print results: list of names and sids returned in this
715 for (i
= 0; i
< domain_list
.count
; i
++) {
716 struct dom_sid_buf sid_str
;
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
,
726 dcerpc_lsa_Close(b
, mem_ctx
, &pol
, &result
);
731 /* Enumerates privileges */
733 static NTSTATUS
cmd_lsa_enum_privilege(struct rpc_pipe_client
*cli
,
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;
748 printf("Usage: %s [enum context] [max length]\n", argv
[0]);
753 enum_context
=atoi(argv
[1]);
756 pref_max_length
=atoi(argv
[2]);
758 status
= rpccli_lsa_open_policy(cli
, mem_ctx
, True
,
759 SEC_FLAG_MAXIMUM_ALLOWED
,
762 if (!NT_STATUS_IS_OK(status
))
765 status
= dcerpc_lsa_EnumPrivs(b
, mem_ctx
,
771 if (!NT_STATUS_IS_OK(status
))
773 if (!NT_STATUS_IS_OK(result
)) {
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
);
795 /* Get privilege name */
797 static NTSTATUS
cmd_lsa_get_dispname(struct rpc_pipe_client
*cli
,
802 struct policy_handle pol
;
803 NTSTATUS status
, result
;
804 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
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
;
813 printf("Usage: %s privilege name\n", argv
[0]);
817 status
= rpccli_lsa_open_policy(cli
, mem_ctx
, True
,
818 SEC_FLAG_MAXIMUM_ALLOWED
,
821 if (!NT_STATUS_IS_OK(status
))
824 init_lsa_String(&lsa_name
, argv
[1]);
826 status
= dcerpc_lsa_LookupPrivDisplayName(b
, mem_ctx
,
834 if (!NT_STATUS_IS_OK(status
))
836 if (!NT_STATUS_IS_OK(result
)) {
842 printf("%s -> %s (language: 0x%x)\n", argv
[1], description
->string
, lang_id_desc
);
844 dcerpc_lsa_Close(b
, mem_ctx
, &pol
, &result
);
849 /* Enumerate the LSA SIDS */
851 static NTSTATUS
cmd_lsa_enum_sids(struct rpc_pipe_client
*cli
,
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
;
866 printf("Usage: %s [enum context] [max length]\n", argv
[0]);
871 enum_context
=atoi(argv
[1]);
874 pref_max_length
=atoi(argv
[2]);
876 status
= rpccli_lsa_open_policy(cli
, mem_ctx
, True
,
877 SEC_FLAG_MAXIMUM_ALLOWED
,
880 if (!NT_STATUS_IS_OK(status
))
883 status
= dcerpc_lsa_EnumAccounts(b
, mem_ctx
,
889 if (!NT_STATUS_IS_OK(status
))
891 if (!NT_STATUS_IS_OK(result
)) {
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
;
903 dom_sid_str_buf(sid_array
.sids
[i
].sid
, &sid_str
));
906 dcerpc_lsa_Close(b
, mem_ctx
, &pol
, &result
);
911 /* Create a new account */
913 static NTSTATUS
cmd_lsa_create_account(struct rpc_pipe_client
*cli
,
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
= {
928 uint32_t out_version
= 0;
933 printf("Usage: %s SID\n", argv
[0]);
937 status
= name_to_sid(cli
, mem_ctx
, &sid
, argv
[1]);
938 if (!NT_STATUS_IS_OK(status
))
941 status
= dcerpc_lsa_open_policy_fallback(b
,
945 SEC_FLAG_MAXIMUM_ALLOWED
,
950 if (any_nt_status_not_ok(status
, result
, &status
)) {
954 status
= dcerpc_lsa_CreateAccount(b
, mem_ctx
,
960 if (!NT_STATUS_IS_OK(status
))
962 if (!NT_STATUS_IS_OK(result
)) {
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
);
976 /* Enumerate the privileges of an SID */
978 static NTSTATUS
cmd_lsa_enum_privsaccounts(struct rpc_pipe_client
*cli
,
983 struct policy_handle dom_pol
;
984 struct policy_handle user_pol
;
985 NTSTATUS status
, result
;
986 uint32_t access_desired
= 0x000f000f;
988 struct lsa_PrivilegeSet
*privs
= NULL
;
990 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
991 union lsa_revision_info out_revision_info
= {
996 uint32_t out_version
= 0;
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
))
1007 status
= dcerpc_lsa_open_policy_fallback(b
,
1009 cli
->srv_name_slash
,
1011 SEC_FLAG_MAXIMUM_ALLOWED
,
1016 if (any_nt_status_not_ok(status
, result
, &status
)) {
1020 status
= dcerpc_lsa_OpenAccount(b
, mem_ctx
,
1026 if (!NT_STATUS_IS_OK(status
))
1028 if (!NT_STATUS_IS_OK(result
)) {
1033 status
= dcerpc_lsa_EnumPrivsAccount(b
, mem_ctx
,
1037 if (!NT_STATUS_IS_OK(status
))
1039 if (!NT_STATUS_IS_OK(result
)) {
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
);
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
,
1068 struct policy_handle dom_pol
;
1069 NTSTATUS status
, result
;
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
= {
1079 uint32_t out_version
= 0;
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
))
1092 status
= dcerpc_lsa_open_policy_fallback(b
,
1094 cli
->srv_name_slash
,
1096 SEC_FLAG_MAXIMUM_ALLOWED
,
1101 if (any_nt_status_not_ok(status
, result
, &status
)) {
1105 status
= dcerpc_lsa_EnumAccountRights(b
, mem_ctx
,
1110 if (!NT_STATUS_IS_OK(status
))
1112 if (!NT_STATUS_IS_OK(result
)) {
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
);
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
,
1137 struct policy_handle dom_pol
;
1138 NTSTATUS status
, result
;
1139 struct lsa_RightSet rights
;
1142 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
1143 union lsa_revision_info out_revision_info
= {
1148 uint32_t out_version
= 0;
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
))
1159 status
= dcerpc_lsa_open_policy_fallback(b
,
1161 cli
->srv_name_slash
,
1163 SEC_FLAG_MAXIMUM_ALLOWED
,
1168 if (any_nt_status_not_ok(status
, result
, &status
)) {
1172 rights
.count
= argc
-2;
1173 rights
.names
= talloc_array(mem_ctx
, struct lsa_StringLarge
,
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
,
1188 if (!NT_STATUS_IS_OK(status
))
1190 if (!NT_STATUS_IS_OK(result
)) {
1195 dcerpc_lsa_Close(b
, mem_ctx
, &dom_pol
, &result
);
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
,
1208 struct policy_handle dom_pol
;
1209 NTSTATUS status
, result
;
1210 struct lsa_RightSet rights
;
1213 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
1214 union lsa_revision_info out_revision_info
= {
1219 uint32_t out_version
= 0;
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
))
1230 status
= dcerpc_lsa_open_policy_fallback(b
,
1232 cli
->srv_name_slash
,
1234 SEC_FLAG_MAXIMUM_ALLOWED
,
1239 if (any_nt_status_not_ok(status
, result
, &status
)) {
1243 rights
.count
= argc
-2;
1244 rights
.names
= talloc_array(mem_ctx
, struct lsa_StringLarge
,
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
,
1260 if (!NT_STATUS_IS_OK(status
))
1262 if (!NT_STATUS_IS_OK(result
)) {
1267 dcerpc_lsa_Close(b
, mem_ctx
, &dom_pol
, &result
);
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
,
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
= {
1291 uint32_t out_version
= 0;
1294 printf("Usage: %s name\n", argv
[0]);
1295 return NT_STATUS_OK
;
1298 status
= dcerpc_lsa_open_policy_fallback(b
,
1300 cli
->srv_name_slash
,
1302 SEC_FLAG_MAXIMUM_ALLOWED
,
1307 if (any_nt_status_not_ok(status
, result
, &status
)) {
1311 init_lsa_String(&name
, argv
[1]);
1313 status
= dcerpc_lsa_LookupPrivValue(b
, mem_ctx
,
1318 if (!NT_STATUS_IS_OK(status
))
1320 if (!NT_STATUS_IS_OK(result
)) {
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
);
1334 /* Query LSA security object */
1336 static NTSTATUS
cmd_lsa_query_secobj(struct rpc_pipe_client
*cli
,
1337 TALLOC_CTX
*mem_ctx
,
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
= {
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
;
1359 sscanf(argv
[1], "%x", &sec_info
);
1361 status
= dcerpc_lsa_open_policy_fallback(b
,
1363 cli
->srv_name_slash
,
1365 SEC_FLAG_MAXIMUM_ALLOWED
,
1370 if (any_nt_status_not_ok(status
, result
, &status
)) {
1374 status
= dcerpc_lsa_QuerySecurity(b
, mem_ctx
,
1379 if (!NT_STATUS_IS_OK(status
))
1381 if (!NT_STATUS_IS_OK(result
)) {
1388 display_sec_desc(sdb
->sd
);
1390 dcerpc_lsa_Close(b
, mem_ctx
, &pol
, &result
);
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
);
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
);
1423 const char *str
= NULL
;
1424 str
= NDR_PRINT_UNION_STRING(mem_ctx
,
1425 lsa_TrustedDomainInfo
,
1428 d_printf("%s\n", str
);
1435 static NTSTATUS
cmd_lsa_query_trustdominfobysid(struct rpc_pipe_client
*cli
,
1436 TALLOC_CTX
*mem_ctx
,
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
= {
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
;
1464 info_class
= atoi(argv
[2]);
1466 status
= dcerpc_lsa_open_policy_fallback(b
,
1468 cli
->srv_name_slash
,
1475 if (any_nt_status_not_ok(status
, result
, &status
)) {
1479 status
= dcerpc_lsa_QueryTrustedDomainInfoBySid(b
, mem_ctx
,
1485 if (!NT_STATUS_IS_OK(status
))
1487 if (!NT_STATUS_IS_OK(result
)) {
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
)));
1499 display_trust_dom_info(mem_ctx
, info
, info_class
, session_key
);
1502 dcerpc_lsa_Close(b
, mem_ctx
, &pol
, &result
);
1507 static NTSTATUS
cmd_lsa_query_trustdominfobyname(struct rpc_pipe_client
*cli
,
1508 TALLOC_CTX
*mem_ctx
,
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
= {
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
;
1533 info_class
= atoi(argv
[2]);
1535 status
= dcerpc_lsa_open_policy_fallback(b
,
1537 cli
->srv_name_slash
,
1544 if (any_nt_status_not_ok(status
, result
, &status
)) {
1548 init_lsa_String(&trusted_domain
, argv
[1]);
1550 status
= dcerpc_lsa_QueryTrustedDomainInfoByName(b
, mem_ctx
,
1556 if (!NT_STATUS_IS_OK(status
))
1558 if (!NT_STATUS_IS_OK(result
)) {
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
)));
1570 display_trust_dom_info(mem_ctx
, info
, info_class
, session_key
);
1573 dcerpc_lsa_Close(b
, mem_ctx
, &pol
, &result
);
1578 static NTSTATUS
cmd_lsa_set_trustdominfo(struct rpc_pipe_client
*cli
,
1579 TALLOC_CTX
*mem_ctx
, int argc
,
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
= {
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]);
1613 return NT_STATUS_INVALID_PARAMETER
;
1616 status
= dcerpc_lsa_open_policy_fallback(b
,
1618 cli
->srv_name_slash
,
1625 if (any_nt_status_not_ok(status
, result
, &status
)) {
1629 status
= dcerpc_lsa_OpenTrustedDomain(b
, mem_ctx
,
1635 if (!NT_STATUS_IS_OK(status
)) {
1638 if (!NT_STATUS_IS_OK(result
)) {
1643 status
= dcerpc_lsa_SetInformationTrustedDomain(b
, mem_ctx
,
1648 if (!NT_STATUS_IS_OK(status
)) {
1651 if (!NT_STATUS_IS_OK(result
)) {
1656 dcerpc_lsa_Close(b
, mem_ctx
, &trustdom_pol
, &result
);
1657 dcerpc_lsa_Close(b
, mem_ctx
, &pol
, &result
);
1662 static NTSTATUS
cmd_lsa_query_trustdominfo(struct rpc_pipe_client
*cli
,
1663 TALLOC_CTX
*mem_ctx
,
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
= {
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
;
1692 info_class
= atoi(argv
[2]);
1694 status
= dcerpc_lsa_open_policy_fallback(b
,
1696 cli
->srv_name_slash
,
1703 if (any_nt_status_not_ok(status
, result
, &status
)) {
1707 status
= dcerpc_lsa_OpenTrustedDomain(b
, mem_ctx
,
1713 if (!NT_STATUS_IS_OK(status
))
1715 if (!NT_STATUS_IS_OK(result
)) {
1720 status
= dcerpc_lsa_QueryTrustedDomainInfo(b
, mem_ctx
,
1725 if (!NT_STATUS_IS_OK(status
))
1727 if (!NT_STATUS_IS_OK(result
)) {
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
)));
1739 display_trust_dom_info(mem_ctx
, info
, info_class
, session_key
);
1742 dcerpc_lsa_Close(b
, mem_ctx
, &pol
, &result
);
1747 static NTSTATUS
cmd_lsa_get_username(struct rpc_pipe_client
*cli
,
1748 TALLOC_CTX
*mem_ctx
, int argc
,
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
;
1758 printf("Usage: %s servername\n", argv
[0]);
1759 return NT_STATUS_OK
;
1762 status
= dcerpc_lsa_GetUserName(b
, mem_ctx
,
1767 if (!NT_STATUS_IS_OK(status
)) {
1770 if (!NT_STATUS_IS_OK(result
)) {
1777 printf("Account Name: %s, Authority Name: %s\n",
1778 account_name
->string
, authority_name
? authority_name
->string
:
1785 static NTSTATUS
cmd_lsa_add_priv(struct rpc_pipe_client
*cli
,
1786 TALLOC_CTX
*mem_ctx
, int argc
,
1789 struct policy_handle dom_pol
, user_pol
;
1790 NTSTATUS status
, result
;
1791 struct lsa_PrivilegeSet privs
;
1792 struct lsa_LUIDAttribute
*set
= NULL
;
1795 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
1796 union lsa_revision_info out_revision_info
= {
1801 uint32_t out_version
= 0;
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
)) {
1815 status
= dcerpc_lsa_open_policy_fallback(b
,
1817 cli
->srv_name_slash
,
1819 SEC_FLAG_MAXIMUM_ALLOWED
,
1824 if (any_nt_status_not_ok(status
, result
, &status
)) {
1828 status
= dcerpc_lsa_OpenAccount(b
, mem_ctx
,
1831 SEC_FLAG_MAXIMUM_ALLOWED
,
1834 if (!NT_STATUS_IS_OK(status
)) {
1837 if (!NT_STATUS_IS_OK(result
)) {
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
,
1854 if (!NT_STATUS_IS_OK(status
)) {
1857 if (!NT_STATUS_IS_OK(result
)) {
1863 set
= talloc_realloc(mem_ctx
, set
,
1864 struct lsa_LUIDAttribute
,
1867 return NT_STATUS_NO_MEMORY
;
1870 set
[privs
.count
-1].luid
= luid
;
1871 set
[privs
.count
-1].attribute
= 0;
1876 status
= dcerpc_lsa_AddPrivilegesToAccount(b
, mem_ctx
,
1880 if (!NT_STATUS_IS_OK(status
)) {
1883 if (!NT_STATUS_IS_OK(result
)) {
1888 dcerpc_lsa_Close(b
, mem_ctx
, &user_pol
, &result
);
1889 dcerpc_lsa_Close(b
, mem_ctx
, &dom_pol
, &result
);
1894 static NTSTATUS
cmd_lsa_del_priv(struct rpc_pipe_client
*cli
,
1895 TALLOC_CTX
*mem_ctx
, int argc
,
1898 struct policy_handle dom_pol
, user_pol
;
1899 NTSTATUS status
, result
;
1900 struct lsa_PrivilegeSet privs
;
1901 struct lsa_LUIDAttribute
*set
= NULL
;
1904 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
1905 union lsa_revision_info out_revision_info
= {
1910 uint32_t out_version
= 0;
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
)) {
1924 status
= dcerpc_lsa_open_policy_fallback(b
,
1926 cli
->srv_name_slash
,
1928 SEC_FLAG_MAXIMUM_ALLOWED
,
1933 if (any_nt_status_not_ok(status
, result
, &status
)) {
1937 status
= dcerpc_lsa_OpenAccount(b
, mem_ctx
,
1940 SEC_FLAG_MAXIMUM_ALLOWED
,
1943 if (!NT_STATUS_IS_OK(status
)) {
1946 if (!NT_STATUS_IS_OK(result
)) {
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
,
1963 if (!NT_STATUS_IS_OK(status
)) {
1966 if (!NT_STATUS_IS_OK(result
)) {
1972 set
= talloc_realloc(mem_ctx
, set
,
1973 struct lsa_LUIDAttribute
,
1976 return NT_STATUS_NO_MEMORY
;
1979 set
[privs
.count
-1].luid
= luid
;
1980 set
[privs
.count
-1].attribute
= 0;
1986 status
= dcerpc_lsa_RemovePrivilegesFromAccount(b
, mem_ctx
,
1991 if (!NT_STATUS_IS_OK(status
)) {
1994 if (!NT_STATUS_IS_OK(result
)) {
1999 dcerpc_lsa_Close(b
, mem_ctx
, &user_pol
, &result
);
2000 dcerpc_lsa_Close(b
, mem_ctx
, &dom_pol
, &result
);
2005 static NTSTATUS
cmd_lsa_create_secret(struct rpc_pipe_client
*cli
,
2006 TALLOC_CTX
*mem_ctx
, int argc
,
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
= {
2018 uint32_t out_version
= 0;
2021 printf("Usage: %s name\n", argv
[0]);
2022 return NT_STATUS_OK
;
2025 status
= dcerpc_lsa_open_policy_fallback(b
,
2027 cli
->srv_name_slash
,
2029 SEC_FLAG_MAXIMUM_ALLOWED
,
2034 if (any_nt_status_not_ok(status
, result
, &status
)) {
2038 init_lsa_String(&name
, argv
[1]);
2040 status
= dcerpc_lsa_CreateSecret(b
, mem_ctx
,
2043 SEC_FLAG_MAXIMUM_ALLOWED
,
2046 if (!NT_STATUS_IS_OK(status
)) {
2049 if (!NT_STATUS_IS_OK(result
)) {
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
);
2065 static NTSTATUS
cmd_lsa_delete_secret(struct rpc_pipe_client
*cli
,
2066 TALLOC_CTX
*mem_ctx
, int argc
,
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
= {
2078 uint32_t out_version
= 0;
2081 printf("Usage: %s name\n", argv
[0]);
2082 return NT_STATUS_OK
;
2085 status
= dcerpc_lsa_open_policy_fallback(b
,
2087 cli
->srv_name_slash
,
2089 SEC_FLAG_MAXIMUM_ALLOWED
,
2094 if (any_nt_status_not_ok(status
, result
, &status
)) {
2098 init_lsa_String(&name
, argv
[1]);
2100 status
= dcerpc_lsa_OpenSecret(b
, mem_ctx
,
2103 SEC_FLAG_MAXIMUM_ALLOWED
,
2106 if (!NT_STATUS_IS_OK(status
)) {
2109 if (!NT_STATUS_IS_OK(result
)) {
2114 status
= dcerpc_lsa_DeleteObject(b
, mem_ctx
,
2117 if (!NT_STATUS_IS_OK(status
)) {
2120 if (!NT_STATUS_IS_OK(result
)) {
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
);
2136 static NTSTATUS
cmd_lsa_query_secret(struct rpc_pipe_client
*cli
,
2137 TALLOC_CTX
*mem_ctx
, int argc
,
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
= {
2157 uint32_t out_version
= 0;
2160 printf("Usage: %s name\n", argv
[0]);
2161 return NT_STATUS_OK
;
2164 status
= dcerpc_lsa_open_policy_fallback(b
,
2166 cli
->srv_name_slash
,
2168 SEC_FLAG_MAXIMUM_ALLOWED
,
2173 if (any_nt_status_not_ok(status
, result
, &status
)) {
2177 init_lsa_String(&name
, argv
[1]);
2179 status
= dcerpc_lsa_OpenSecret(b
, mem_ctx
,
2182 SEC_FLAG_MAXIMUM_ALLOWED
,
2185 if (!NT_STATUS_IS_OK(status
)) {
2188 if (!NT_STATUS_IS_OK(result
)) {
2193 ZERO_STRUCT(new_val
);
2194 ZERO_STRUCT(old_val
);
2196 status
= dcerpc_lsa_QuerySecret(b
, mem_ctx
,
2203 if (!NT_STATUS_IS_OK(status
)) {
2206 if (!NT_STATUS_IS_OK(result
)) {
2211 status
= dcerpc_binding_handle_transport_session_key(
2212 b
, mem_ctx
, &session_key
);
2213 if (!NT_STATUS_IS_OK(status
)) {
2218 new_blob
= data_blob_const(new_val
.buf
->data
, new_val
.buf
->length
);
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
);
2227 d_printf("new secret: %s\n", new_secret
);
2230 d_printf("old secret: %s\n", old_secret
);
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
);
2244 static NTSTATUS
cmd_lsa_set_secret(struct rpc_pipe_client
*cli
,
2245 TALLOC_CTX
*mem_ctx
, int argc
,
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
;
2254 DATA_BLOB session_key
;
2255 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
2256 union lsa_revision_info out_revision_info
= {
2261 uint32_t out_version
= 0;
2264 printf("Usage: %s name secret\n", argv
[0]);
2265 return NT_STATUS_OK
;
2268 status
= dcerpc_lsa_open_policy_fallback(b
,
2270 cli
->srv_name_slash
,
2272 SEC_FLAG_MAXIMUM_ALLOWED
,
2277 if (any_nt_status_not_ok(status
, result
, &status
)) {
2281 init_lsa_String(&name
, argv
[1]);
2283 status
= dcerpc_lsa_OpenSecret(b
, mem_ctx
,
2286 SEC_FLAG_MAXIMUM_ALLOWED
,
2289 if (!NT_STATUS_IS_OK(status
)) {
2292 if (!NT_STATUS_IS_OK(result
)) {
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
)) {
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
,
2317 if (!NT_STATUS_IS_OK(status
)) {
2320 if (!NT_STATUS_IS_OK(result
)) {
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
);
2336 static NTSTATUS
cmd_lsa_retrieve_private_data(struct rpc_pipe_client
*cli
,
2337 TALLOC_CTX
*mem_ctx
, int argc
,
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
;
2347 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
2348 union lsa_revision_info out_revision_info
= {
2353 uint32_t out_version
= 0;
2356 printf("Usage: %s name\n", argv
[0]);
2357 return NT_STATUS_OK
;
2360 status
= dcerpc_lsa_open_policy_fallback(b
,
2362 cli
->srv_name_slash
,
2364 SEC_FLAG_MAXIMUM_ALLOWED
,
2369 if (any_nt_status_not_ok(status
, result
, &status
)) {
2373 init_lsa_String(&name
, argv
[1]);
2377 status
= dcerpc_lsa_RetrievePrivateData(b
, mem_ctx
,
2382 if (!NT_STATUS_IS_OK(status
)) {
2385 if (!NT_STATUS_IS_OK(result
)) {
2390 status
= dcerpc_binding_handle_transport_session_key(
2391 b
, mem_ctx
, &session_key
);
2392 if (!NT_STATUS_IS_OK(status
)) {
2397 blob
= data_blob_const(val
->data
, val
->length
);
2400 secret
= sess_decrypt_string(mem_ctx
, &blob
, &session_key
);
2402 d_printf("secret: %s\n", secret
);
2406 if (is_valid_policy_hnd(&handle
)) {
2407 dcerpc_lsa_Close(b
, mem_ctx
, &handle
, &result
);
2413 static NTSTATUS
cmd_lsa_store_private_data(struct rpc_pipe_client
*cli
,
2414 TALLOC_CTX
*mem_ctx
, int argc
,
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
;
2423 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
2424 union lsa_revision_info out_revision_info
= {
2429 uint32_t out_version
= 0;
2432 printf("Usage: %s name secret\n", argv
[0]);
2433 return NT_STATUS_OK
;
2436 status
= dcerpc_lsa_open_policy_fallback(b
,
2438 cli
->srv_name_slash
,
2440 SEC_FLAG_MAXIMUM_ALLOWED
,
2445 if (any_nt_status_not_ok(status
, result
, &status
)) {
2449 init_lsa_String(&name
, argv
[1]);
2453 status
= dcerpc_binding_handle_transport_session_key(
2454 b
, mem_ctx
, &session_key
);
2455 if (!NT_STATUS_IS_OK(status
)) {
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
,
2470 if (!NT_STATUS_IS_OK(status
)) {
2473 if (!NT_STATUS_IS_OK(result
)) {
2479 if (is_valid_policy_hnd(&handle
)) {
2480 dcerpc_lsa_Close(b
, mem_ctx
, &handle
, &result
);
2486 static NTSTATUS
cmd_lsa_create_trusted_domain(struct rpc_pipe_client
*cli
,
2487 TALLOC_CTX
*mem_ctx
, int argc
,
2490 NTSTATUS status
, result
;
2491 struct policy_handle handle
, trustdom_handle
;
2493 struct lsa_DomainInfo info
;
2494 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
2495 union lsa_revision_info out_revision_info
= {
2500 uint32_t out_version
= 0;
2503 printf("Usage: %s name sid\n", argv
[0]);
2504 return NT_STATUS_OK
;
2507 status
= dcerpc_lsa_open_policy_fallback(b
,
2509 cli
->srv_name_slash
,
2511 SEC_FLAG_MAXIMUM_ALLOWED
,
2516 if (any_nt_status_not_ok(status
, result
, &status
)) {
2520 init_lsa_StringLarge(&info
.name
, argv
[1]);
2522 string_to_sid(&sid
, argv
[2]);
2524 status
= dcerpc_lsa_CreateTrustedDomain(b
, mem_ctx
,
2527 SEC_FLAG_MAXIMUM_ALLOWED
,
2530 if (!NT_STATUS_IS_OK(status
)) {
2533 if (!NT_STATUS_IS_OK(result
)) {
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
);
2550 static NTSTATUS
cmd_lsa_create_trusted_domain_ex3(struct rpc_pipe_client
*cli
,
2551 TALLOC_CTX
*mem_ctx
,
2555 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
2556 struct policy_handle handle
= {
2559 struct policy_handle trustdom_handle
= {
2562 struct dom_sid sid
= {
2565 union lsa_revision_info out_revision_info
= {
2570 struct lsa_TrustDomainInfoAuthInfoInternalAES
*authinfo_internal
= NULL
;
2571 struct lsa_TrustDomainInfoInfoEx trustinfo
= {
2572 .trust_attributes
= 0,
2574 uint32_t out_version
= 0;
2576 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
2577 DATA_BLOB session_key
= {
2583 printf("Usage: %s trust_name trust_dns_name trust_sid "
2584 "trust_directrion trust_type "
2585 "incoming_trustpw outgoing_trustpw\n",
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",
2598 status
= dcerpc_lsa_open_policy_fallback(b
,
2600 cli
->srv_name_slash
,
2602 SEC_FLAG_MAXIMUM_ALLOWED
,
2607 if (any_nt_status_not_ok(status
, result
, &status
)) {
2608 DBG_ERR("Could not open LSA connection: %s\n",
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]);
2618 status
= NT_STATUS_INVALID_PARAMETER
;
2619 DBG_ERR("Could not convert SID: %s\n", nt_errstr(status
));
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
,
2633 &authinfo_internal
);
2635 status
= NT_STATUS_INVALID_PARAMETER
;
2636 DBG_ERR("Could not encrypt trust information: %s\n",
2641 status
= dcerpc_lsa_CreateTrustedDomainEx3(b
,
2646 SEC_FLAG_MAXIMUM_ALLOWED
,
2649 if (any_nt_status_not_ok(status
, result
, &status
)) {
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
);
2665 static NTSTATUS
cmd_lsa_create_trusted_domain_ex2(struct rpc_pipe_client
*cli
,
2666 TALLOC_CTX
*mem_ctx
,
2670 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
2671 struct policy_handle handle
= {
2674 struct policy_handle trustdom_handle
= {
2677 struct dom_sid sid
= {
2680 union lsa_revision_info out_revision_info
= {
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;
2691 NTSTATUS result
= NT_STATUS_UNSUCCESSFUL
;
2692 DATA_BLOB session_key
= {
2698 printf("Usage: %s trust_name trust_dns_name trust_sid "
2699 "trust_directrion trust_type "
2700 "incoming_trustpw outgoing_trustpw\n",
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",
2713 status
= dcerpc_lsa_open_policy_fallback(b
,
2715 cli
->srv_name_slash
,
2717 SEC_FLAG_MAXIMUM_ALLOWED
,
2722 if (any_nt_status_not_ok(status
, result
, &status
)) {
2723 DBG_ERR("Could not open LSA connection: %s\n",
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]);
2733 status
= NT_STATUS_INVALID_PARAMETER
;
2734 DBG_ERR("Could not convert SID: %s\n", nt_errstr(status
));
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
,
2748 &authinfo_internal
);
2750 status
= NT_STATUS_INVALID_PARAMETER
;
2751 DBG_ERR("Could not encrypt trust information: %s\n",
2756 status
= dcerpc_lsa_CreateTrustedDomainEx2(b
,
2761 SEC_FLAG_MAXIMUM_ALLOWED
,
2764 if (any_nt_status_not_ok(status
, result
, &status
)) {
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
);
2780 static NTSTATUS
cmd_lsa_delete_trusted_domain(struct rpc_pipe_client
*cli
,
2781 TALLOC_CTX
*mem_ctx
, int argc
,
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
= {
2794 uint32_t out_version
= 0;
2797 printf("Usage: %s name\n", argv
[0]);
2798 return NT_STATUS_OK
;
2801 status
= dcerpc_lsa_open_policy_fallback(b
,
2803 cli
->srv_name_slash
,
2805 SEC_FLAG_MAXIMUM_ALLOWED
,
2810 if (any_nt_status_not_ok(status
, result
, &status
)) {
2814 init_lsa_String(&name
, argv
[1]);
2816 status
= dcerpc_lsa_OpenTrustedDomainByName(b
, mem_ctx
,
2819 SEC_FLAG_MAXIMUM_ALLOWED
,
2822 if (NT_STATUS_IS_OK(status
) && NT_STATUS_IS_OK(result
)) {
2827 uint32_t resume_handle
= 0;
2828 struct lsa_DomainList domains
;
2831 status
= dcerpc_lsa_EnumTrustDom(b
, mem_ctx
,
2837 if (!NT_STATUS_IS_OK(status
)) {
2840 if (!NT_STATUS_IS_OK(result
)) {
2845 for (i
=0; i
< domains
.count
; i
++) {
2846 if (strequal(domains
.domains
[i
].name
.string
, argv
[1])) {
2847 sid
= domains
.domains
[i
].sid
;
2853 return NT_STATUS_INVALID_SID
;
2857 status
= dcerpc_lsa_OpenTrustedDomain(b
, mem_ctx
,
2860 SEC_FLAG_MAXIMUM_ALLOWED
,
2863 if (!NT_STATUS_IS_OK(status
)) {
2866 if (!NT_STATUS_IS_OK(result
)) {
2872 status
= dcerpc_lsa_DeleteObject(b
, mem_ctx
,
2875 if (!NT_STATUS_IS_OK(status
)) {
2878 if (!NT_STATUS_IS_OK(result
)) {
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
);
2896 /* List of commands exported by this module */
2898 struct cmd_set lsarpc_commands
[] = {
2906 .returntype
= RPC_RTYPE_NTSTATUS
,
2907 .ntfn
= cmd_lsa_query_info_policy
,
2909 .table
= &ndr_table_lsarpc
,
2911 .description
= "Query info policy",
2915 .name
= "lookupsids",
2916 .returntype
= RPC_RTYPE_NTSTATUS
,
2917 .ntfn
= cmd_lsa_lookup_sids
,
2919 .table
= &ndr_table_lsarpc
,
2921 .description
= "Convert SIDs to names",
2925 .name
= "lookupsids3",
2926 .returntype
= RPC_RTYPE_NTSTATUS
,
2927 .ntfn
= cmd_lsa_lookup_sids3
,
2929 .table
= &ndr_table_lsarpc
,
2931 .description
= "Convert SIDs to names",
2935 .name
= "lookupsids_level",
2936 .returntype
= RPC_RTYPE_NTSTATUS
,
2937 .ntfn
= cmd_lsa_lookup_sids_level
,
2939 .table
= &ndr_table_lsarpc
,
2941 .description
= "Convert SIDs to names",
2945 .name
= "lookupnames",
2946 .returntype
= RPC_RTYPE_NTSTATUS
,
2947 .ntfn
= cmd_lsa_lookup_names
,
2949 .table
= &ndr_table_lsarpc
,
2951 .description
= "Convert names to SIDs",
2955 .name
= "lookupnames4",
2956 .returntype
= RPC_RTYPE_NTSTATUS
,
2957 .ntfn
= cmd_lsa_lookup_names4
,
2959 .table
= &ndr_table_lsarpc
,
2961 .description
= "Convert names to SIDs",
2965 .name
= "lookupnames_level",
2966 .returntype
= RPC_RTYPE_NTSTATUS
,
2967 .ntfn
= cmd_lsa_lookup_names_level
,
2969 .table
= &ndr_table_lsarpc
,
2971 .description
= "Convert names to SIDs",
2975 .name
= "enumtrust",
2976 .returntype
= RPC_RTYPE_NTSTATUS
,
2977 .ntfn
= cmd_lsa_enum_trust_dom
,
2979 .table
= &ndr_table_lsarpc
,
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
,
2989 .table
= &ndr_table_lsarpc
,
2991 .description
= "Enumerate privileges",
2995 .name
= "getdispname",
2996 .returntype
= RPC_RTYPE_NTSTATUS
,
2997 .ntfn
= cmd_lsa_get_dispname
,
2999 .table
= &ndr_table_lsarpc
,
3001 .description
= "Get the privilege name",
3005 .name
= "lsaenumsid",
3006 .returntype
= RPC_RTYPE_NTSTATUS
,
3007 .ntfn
= cmd_lsa_enum_sids
,
3009 .table
= &ndr_table_lsarpc
,
3011 .description
= "Enumerate the LSA SIDS",
3015 .name
= "lsacreateaccount",
3016 .returntype
= RPC_RTYPE_NTSTATUS
,
3017 .ntfn
= cmd_lsa_create_account
,
3019 .table
= &ndr_table_lsarpc
,
3021 .description
= "Create a new lsa account",
3025 .name
= "lsaenumprivsaccount",
3026 .returntype
= RPC_RTYPE_NTSTATUS
,
3027 .ntfn
= cmd_lsa_enum_privsaccounts
,
3029 .table
= &ndr_table_lsarpc
,
3031 .description
= "Enumerate the privileges of an SID",
3035 .name
= "lsaenumacctrights",
3036 .returntype
= RPC_RTYPE_NTSTATUS
,
3037 .ntfn
= cmd_lsa_enum_acct_rights
,
3039 .table
= &ndr_table_lsarpc
,
3041 .description
= "Enumerate the rights of an SID",
3045 .name
= "lsaaddpriv",
3046 .returntype
= RPC_RTYPE_NTSTATUS
,
3047 .ntfn
= cmd_lsa_add_priv
,
3049 .table
= &ndr_table_lsarpc
,
3051 .description
= "Assign a privilege to a SID",
3055 .name
= "lsadelpriv",
3056 .returntype
= RPC_RTYPE_NTSTATUS
,
3057 .ntfn
= cmd_lsa_del_priv
,
3059 .table
= &ndr_table_lsarpc
,
3061 .description
= "Revoke a privilege from a SID",
3065 .name
= "lsaaddacctrights",
3066 .returntype
= RPC_RTYPE_NTSTATUS
,
3067 .ntfn
= cmd_lsa_add_acct_rights
,
3069 .table
= &ndr_table_lsarpc
,
3071 .description
= "Add rights to an account",
3075 .name
= "lsaremoveacctrights",
3076 .returntype
= RPC_RTYPE_NTSTATUS
,
3077 .ntfn
= cmd_lsa_remove_acct_rights
,
3079 .table
= &ndr_table_lsarpc
,
3081 .description
= "Remove rights from an account",
3085 .name
= "lsalookupprivvalue",
3086 .returntype
= RPC_RTYPE_NTSTATUS
,
3087 .ntfn
= cmd_lsa_lookup_priv_value
,
3089 .table
= &ndr_table_lsarpc
,
3091 .description
= "Get a privilege value given its name",
3095 .name
= "lsaquerysecobj",
3096 .returntype
= RPC_RTYPE_NTSTATUS
,
3097 .ntfn
= cmd_lsa_query_secobj
,
3099 .table
= &ndr_table_lsarpc
,
3101 .description
= "Query LSA security object",
3105 .name
= "lsaquerytrustdominfo",
3106 .returntype
= RPC_RTYPE_NTSTATUS
,
3107 .ntfn
= cmd_lsa_query_trustdominfo
,
3109 .table
= &ndr_table_lsarpc
,
3111 .description
= "Query LSA trusted domains info (given a SID)",
3115 .name
= "lsaquerytrustdominfobyname",
3116 .returntype
= RPC_RTYPE_NTSTATUS
,
3117 .ntfn
= cmd_lsa_query_trustdominfobyname
,
3119 .table
= &ndr_table_lsarpc
,
3121 .description
= "Query LSA trusted domains info (given a name), only works for Windows > 2k",
3125 .name
= "lsaquerytrustdominfobysid",
3126 .returntype
= RPC_RTYPE_NTSTATUS
,
3127 .ntfn
= cmd_lsa_query_trustdominfobysid
,
3129 .table
= &ndr_table_lsarpc
,
3131 .description
= "Query LSA trusted domains info (given a SID)",
3135 .name
= "lsasettrustdominfo",
3136 .returntype
= RPC_RTYPE_NTSTATUS
,
3137 .ntfn
= cmd_lsa_set_trustdominfo
,
3139 .table
= &ndr_table_lsarpc
,
3141 .description
= "Set LSA trusted domain info",
3145 .name
= "getusername",
3146 .returntype
= RPC_RTYPE_NTSTATUS
,
3147 .ntfn
= cmd_lsa_get_username
,
3149 .table
= &ndr_table_lsarpc
,
3151 .description
= "Get username",
3155 .name
= "createsecret",
3156 .returntype
= RPC_RTYPE_NTSTATUS
,
3157 .ntfn
= cmd_lsa_create_secret
,
3159 .table
= &ndr_table_lsarpc
,
3161 .description
= "Create Secret",
3165 .name
= "deletesecret",
3166 .returntype
= RPC_RTYPE_NTSTATUS
,
3167 .ntfn
= cmd_lsa_delete_secret
,
3169 .table
= &ndr_table_lsarpc
,
3171 .description
= "Delete Secret",
3175 .name
= "querysecret",
3176 .returntype
= RPC_RTYPE_NTSTATUS
,
3177 .ntfn
= cmd_lsa_query_secret
,
3179 .table
= &ndr_table_lsarpc
,
3181 .description
= "Query Secret",
3185 .name
= "setsecret",
3186 .returntype
= RPC_RTYPE_NTSTATUS
,
3187 .ntfn
= cmd_lsa_set_secret
,
3189 .table
= &ndr_table_lsarpc
,
3191 .description
= "Set Secret",
3195 .name
= "retrieveprivatedata",
3196 .returntype
= RPC_RTYPE_NTSTATUS
,
3197 .ntfn
= cmd_lsa_retrieve_private_data
,
3199 .table
= &ndr_table_lsarpc
,
3201 .description
= "Retrieve Private Data",
3205 .name
= "storeprivatedata",
3206 .returntype
= RPC_RTYPE_NTSTATUS
,
3207 .ntfn
= cmd_lsa_store_private_data
,
3209 .table
= &ndr_table_lsarpc
,
3211 .description
= "Store Private Data",
3215 .name
= "createtrustdom",
3216 .returntype
= RPC_RTYPE_NTSTATUS
,
3217 .ntfn
= cmd_lsa_create_trusted_domain
,
3219 .table
= &ndr_table_lsarpc
,
3221 .description
= "Create Trusted Domain",
3225 .name
= "createtrustdomex2",
3226 .returntype
= RPC_RTYPE_NTSTATUS
,
3227 .ntfn
= cmd_lsa_create_trusted_domain_ex2
,
3229 .table
= &ndr_table_lsarpc
,
3231 .description
= "Create Trusted Domain (Ex2 Variant)",
3235 .name
= "createtrustdomex3",
3236 .returntype
= RPC_RTYPE_NTSTATUS
,
3237 .ntfn
= cmd_lsa_create_trusted_domain_ex3
,
3239 .table
= &ndr_table_lsarpc
,
3241 .description
= "Create Trusted Domain (Ex3 Variant)",
3245 .name
= "deletetrustdom",
3246 .returntype
= RPC_RTYPE_NTSTATUS
,
3247 .ntfn
= cmd_lsa_delete_trusted_domain
,
3249 .table
= &ndr_table_lsarpc
,
3251 .description
= "Delete Trusted Domain",