2 Unix SMB/CIFS implementation.
5 Copyright (C) Andrew Tridgell 1992-2000,
6 Copyright (C) Luke Kenneth Casson Leighton 1996-2000,
7 Copyright (C) Elrond 2000,
8 Copyright (C) Tim Potter 2000
9 Copyright (C) Guenther Deschner 2008
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 3 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program. If not, see <http://www.gnu.org/licenses/>.
26 #include "rpcclient.h"
27 #include "../libcli/auth/libcli_auth.h"
28 #include "../librpc/gen_ndr/ndr_samr.h"
29 #include "../librpc/gen_ndr/ndr_samr_c.h"
30 #include "rpc_client/cli_samr.h"
31 #include "rpc_client/init_samr.h"
32 #include "rpc_client/init_lsa.h"
33 #include "../libcli/security/security.h"
35 extern struct dom_sid domain_sid
;
37 /****************************************************************************
38 display samr_user_info_7 structure
39 ****************************************************************************/
40 static void display_samr_user_info_7(struct samr_UserInfo7
*r
)
42 printf("\tUser Name :\t%s\n", r
->account_name
.string
);
45 /****************************************************************************
46 display samr_user_info_9 structure
47 ****************************************************************************/
48 static void display_samr_user_info_9(struct samr_UserInfo9
*r
)
50 printf("\tPrimary group RID :\tox%x\n", r
->primary_gid
);
53 /****************************************************************************
54 display samr_user_info_16 structure
55 ****************************************************************************/
56 static void display_samr_user_info_16(struct samr_UserInfo16
*r
)
58 printf("\tAcct Flags :\tox%x\n", r
->acct_flags
);
61 /****************************************************************************
62 display samr_user_info_20 structure
63 ****************************************************************************/
64 static void display_samr_user_info_20(struct samr_UserInfo20
*r
)
66 printf("\tRemote Dial :\n");
67 dump_data(0, (uint8_t *)r
->parameters
.array
, r
->parameters
.length
*2);
71 /****************************************************************************
72 display samr_user_info_21 structure
73 ****************************************************************************/
74 static void display_samr_user_info_21(struct samr_UserInfo21
*r
)
76 printf("\tUser Name :\t%s\n", r
->account_name
.string
);
77 printf("\tFull Name :\t%s\n", r
->full_name
.string
);
78 printf("\tHome Drive :\t%s\n", r
->home_directory
.string
);
79 printf("\tDir Drive :\t%s\n", r
->home_drive
.string
);
80 printf("\tProfile Path:\t%s\n", r
->profile_path
.string
);
81 printf("\tLogon Script:\t%s\n", r
->logon_script
.string
);
82 printf("\tDescription :\t%s\n", r
->description
.string
);
83 printf("\tWorkstations:\t%s\n", r
->workstations
.string
);
84 printf("\tComment :\t%s\n", r
->comment
.string
);
85 printf("\tRemote Dial :\n");
86 dump_data(0, (uint8_t *)r
->parameters
.array
, r
->parameters
.length
*2);
88 printf("\tLogon Time :\t%s\n",
89 http_timestring(talloc_tos(), nt_time_to_unix(r
->last_logon
)));
90 printf("\tLogoff Time :\t%s\n",
91 http_timestring(talloc_tos(), nt_time_to_unix(r
->last_logoff
)));
92 printf("\tKickoff Time :\t%s\n",
93 http_timestring(talloc_tos(), nt_time_to_unix(r
->acct_expiry
)));
94 printf("\tPassword last set Time :\t%s\n",
95 http_timestring(talloc_tos(), nt_time_to_unix(r
->last_password_change
)));
96 printf("\tPassword can change Time :\t%s\n",
97 http_timestring(talloc_tos(), nt_time_to_unix(r
->allow_password_change
)));
98 printf("\tPassword must change Time:\t%s\n",
99 http_timestring(talloc_tos(), nt_time_to_unix(r
->force_password_change
)));
101 printf("\tunknown_2[0..31]...\n"); /* user passwords? */
103 printf("\tuser_rid :\t0x%x\n" , r
->rid
); /* User ID */
104 printf("\tgroup_rid:\t0x%x\n" , r
->primary_gid
); /* Group ID */
105 printf("\tacb_info :\t0x%08x\n", r
->acct_flags
); /* Account Control Info */
107 printf("\tfields_present:\t0x%08x\n", r
->fields_present
); /* 0x00ff ffff */
108 printf("\tlogon_divs:\t%d\n", r
->logon_hours
.units_per_week
); /* 0x0000 00a8 which is 168 which is num hrs in a week */
109 printf("\tbad_password_count:\t0x%08x\n", r
->bad_password_count
);
110 printf("\tlogon_count:\t0x%08x\n", r
->logon_count
);
112 printf("\tpadding1[0..7]...\n");
114 if (r
->logon_hours
.bits
) {
115 printf("\tlogon_hrs[0..%d]...\n", r
->logon_hours
.units_per_week
/8);
120 static void display_password_properties(uint32_t password_properties
)
122 printf("password_properties: 0x%08x\n", password_properties
);
124 if (password_properties
& DOMAIN_PASSWORD_COMPLEX
)
125 printf("\tDOMAIN_PASSWORD_COMPLEX\n");
127 if (password_properties
& DOMAIN_PASSWORD_NO_ANON_CHANGE
)
128 printf("\tDOMAIN_PASSWORD_NO_ANON_CHANGE\n");
130 if (password_properties
& DOMAIN_PASSWORD_NO_CLEAR_CHANGE
)
131 printf("\tDOMAIN_PASSWORD_NO_CLEAR_CHANGE\n");
133 if (password_properties
& DOMAIN_PASSWORD_LOCKOUT_ADMINS
)
134 printf("\tDOMAIN_PASSWORD_LOCKOUT_ADMINS\n");
136 if (password_properties
& DOMAIN_PASSWORD_STORE_CLEARTEXT
)
137 printf("\tDOMAIN_PASSWORD_STORE_CLEARTEXT\n");
139 if (password_properties
& DOMAIN_REFUSE_PASSWORD_CHANGE
)
140 printf("\tDOMAIN_REFUSE_PASSWORD_CHANGE\n");
143 static void display_sam_dom_info_1(struct samr_DomInfo1
*info1
)
145 printf("Minimum password length:\t\t\t%d\n",
146 info1
->min_password_length
);
147 printf("Password uniqueness (remember x passwords):\t%d\n",
148 info1
->password_history_length
);
149 display_password_properties(info1
->password_properties
);
150 printf("password expire in:\t\t\t\t%s\n",
151 display_time(info1
->max_password_age
));
152 printf("Min password age (allow changing in x days):\t%s\n",
153 display_time(info1
->min_password_age
));
156 static void display_sam_dom_info_2(struct samr_DomGeneralInformation
*general
)
158 printf("Domain:\t\t%s\n", general
->domain_name
.string
);
159 printf("Server:\t\t%s\n", general
->primary
.string
);
160 printf("Comment:\t%s\n", general
->oem_information
.string
);
162 printf("Total Users:\t%d\n", general
->num_users
);
163 printf("Total Groups:\t%d\n", general
->num_groups
);
164 printf("Total Aliases:\t%d\n", general
->num_aliases
);
166 printf("Sequence No:\t%llu\n", (unsigned long long)general
->sequence_num
);
168 printf("Force Logoff:\t%d\n",
169 (int)nt_time_to_unix_abs(&general
->force_logoff_time
));
171 printf("Domain Server State:\t0x%x\n", general
->domain_server_state
);
172 printf("Server Role:\t%s\n", server_role_str(general
->role
));
173 printf("Unknown 3:\t0x%x\n", general
->unknown3
);
176 static void display_sam_dom_info_3(struct samr_DomInfo3
*info3
)
178 printf("Force Logoff:\t%d\n",
179 (int)nt_time_to_unix_abs(&info3
->force_logoff_time
));
182 static void display_sam_dom_info_4(struct samr_DomOEMInformation
*oem
)
184 printf("Comment:\t%s\n", oem
->oem_information
.string
);
187 static void display_sam_dom_info_5(struct samr_DomInfo5
*info5
)
189 printf("Domain:\t\t%s\n", info5
->domain_name
.string
);
192 static void display_sam_dom_info_6(struct samr_DomInfo6
*info6
)
194 printf("Server:\t\t%s\n", info6
->primary
.string
);
197 static void display_sam_dom_info_7(struct samr_DomInfo7
*info7
)
199 printf("Server Role:\t%s\n", server_role_str(info7
->role
));
202 static void display_sam_dom_info_8(struct samr_DomInfo8
*info8
)
204 printf("Sequence No:\t%llu\n", (unsigned long long)info8
->sequence_num
);
205 printf("Domain Create Time:\t%s\n",
206 http_timestring(talloc_tos(), nt_time_to_unix(info8
->domain_create_time
)));
209 static void display_sam_dom_info_9(struct samr_DomInfo9
*info9
)
211 printf("Domain Server State:\t0x%x\n", info9
->domain_server_state
);
214 static void display_sam_dom_info_12(struct samr_DomInfo12
*info12
)
216 printf("Bad password lockout duration: %s\n",
217 display_time(info12
->lockout_duration
));
218 printf("Reset Lockout after: %s\n",
219 display_time(info12
->lockout_window
));
220 printf("Lockout after bad attempts: %d\n",
221 info12
->lockout_threshold
);
224 static void display_sam_dom_info_13(struct samr_DomInfo13
*info13
)
226 printf("Sequence No:\t%llu\n", (unsigned long long)info13
->sequence_num
);
227 printf("Domain Create Time:\t%s\n",
228 http_timestring(talloc_tos(), nt_time_to_unix(info13
->domain_create_time
)));
229 printf("Sequence No at last promotion:\t%llu\n",
230 (unsigned long long)info13
->modified_count_at_last_promotion
);
233 static void display_sam_info_1(struct samr_DispEntryGeneral
*r
)
235 printf("index: 0x%x ", r
->idx
);
236 printf("RID: 0x%x ", r
->rid
);
237 printf("acb: 0x%08x ", r
->acct_flags
);
238 printf("Account: %s\t", r
->account_name
.string
);
239 printf("Name: %s\t", r
->full_name
.string
);
240 printf("Desc: %s\n", r
->description
.string
);
243 static void display_sam_info_2(struct samr_DispEntryFull
*r
)
245 printf("index: 0x%x ", r
->idx
);
246 printf("RID: 0x%x ", r
->rid
);
247 printf("acb: 0x%08x ", r
->acct_flags
);
248 printf("Account: %s\t", r
->account_name
.string
);
249 printf("Desc: %s\n", r
->description
.string
);
252 static void display_sam_info_3(struct samr_DispEntryFullGroup
*r
)
254 printf("index: 0x%x ", r
->idx
);
255 printf("RID: 0x%x ", r
->rid
);
256 printf("acb: 0x%08x ", r
->acct_flags
);
257 printf("Account: %s\t", r
->account_name
.string
);
258 printf("Desc: %s\n", r
->description
.string
);
261 static void display_sam_info_4(struct samr_DispEntryAscii
*r
)
263 printf("index: 0x%x ", r
->idx
);
264 printf("Account: %s\n", r
->account_name
.string
);
267 static void display_sam_info_5(struct samr_DispEntryAscii
*r
)
269 printf("index: 0x%x ", r
->idx
);
270 printf("Account: %s\n", r
->account_name
.string
);
273 /****************************************************************************
274 ****************************************************************************/
276 static NTSTATUS
get_domain_handle(struct rpc_pipe_client
*cli
,
279 struct policy_handle
*connect_pol
,
280 uint32_t access_mask
,
281 struct dom_sid
*_domain_sid
,
282 struct policy_handle
*domain_pol
)
284 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
285 NTSTATUS status
= NT_STATUS_INVALID_PARAMETER
, result
;
287 if (strcasecmp_m(sam
, "domain") == 0) {
288 status
= dcerpc_samr_OpenDomain(b
, mem_ctx
,
294 } else if (strcasecmp_m(sam
, "builtin") == 0) {
295 status
= dcerpc_samr_OpenDomain(b
, mem_ctx
,
298 discard_const_p(struct dom_sid2
, &global_sid_Builtin
),
303 if (!NT_STATUS_IS_OK(status
)) {
310 /**********************************************************************
311 * Query user information
313 static NTSTATUS
cmd_samr_query_user(struct rpc_pipe_client
*cli
,
315 int argc
, const char **argv
)
317 struct policy_handle connect_pol
, domain_pol
, user_pol
;
318 NTSTATUS status
, result
;
319 uint32_t info_level
= 21;
320 uint32_t access_mask
= MAXIMUM_ALLOWED_ACCESS
;
321 union samr_UserInfo
*info
= NULL
;
322 uint32_t user_rid
= 0;
323 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
325 if ((argc
< 2) || (argc
> 4)) {
326 printf("Usage: %s rid [info level] [access mask] \n", argv
[0]);
330 sscanf(argv
[1], "%i", &user_rid
);
333 sscanf(argv
[2], "%i", &info_level
);
336 sscanf(argv
[3], "%x", &access_mask
);
339 status
= rpccli_try_samr_connects(cli
, mem_ctx
,
340 MAXIMUM_ALLOWED_ACCESS
,
342 if (!NT_STATUS_IS_OK(status
)) {
346 status
= dcerpc_samr_OpenDomain(b
, mem_ctx
,
348 MAXIMUM_ALLOWED_ACCESS
,
352 if (!NT_STATUS_IS_OK(status
)) {
355 if (!NT_STATUS_IS_OK(result
)) {
360 status
= dcerpc_samr_OpenUser(b
, mem_ctx
,
366 if (!NT_STATUS_IS_OK(status
)) {
369 if (NT_STATUS_EQUAL(result
, NT_STATUS_NO_SUCH_USER
) &&
372 /* Probably this was a user name, try lookupnames */
373 struct samr_Ids rids
, types
;
374 struct lsa_String lsa_acct_name
;
376 init_lsa_String(&lsa_acct_name
, argv
[1]);
378 status
= dcerpc_samr_LookupNames(b
, mem_ctx
,
385 if (!NT_STATUS_IS_OK(status
)) {
389 if (NT_STATUS_IS_OK(result
)) {
390 if (rids
.count
!= 1) {
391 status
= NT_STATUS_INVALID_NETWORK_RESPONSE
;
394 if (types
.count
!= 1) {
395 status
= NT_STATUS_INVALID_NETWORK_RESPONSE
;
399 status
= dcerpc_samr_OpenUser(b
, mem_ctx
,
405 if (!NT_STATUS_IS_OK(status
)) {
412 if (!NT_STATUS_IS_OK(result
)) {
417 status
= dcerpc_samr_QueryUserInfo(b
, mem_ctx
,
422 if (!NT_STATUS_IS_OK(status
)) {
425 if (!NT_STATUS_IS_OK(result
)) {
430 switch (info_level
) {
432 display_samr_user_info_7(&info
->info7
);
435 display_samr_user_info_9(&info
->info9
);
438 display_samr_user_info_16(&info
->info16
);
441 display_samr_user_info_20(&info
->info20
);
444 display_samr_user_info_21(&info
->info21
);
447 printf("Unsupported infolevel: %d\n", info_level
);
451 dcerpc_samr_Close(b
, mem_ctx
, &user_pol
, &result
);
452 dcerpc_samr_Close(b
, mem_ctx
, &domain_pol
, &result
);
453 dcerpc_samr_Close(b
, mem_ctx
, &connect_pol
, &result
);
459 /****************************************************************************
461 ****************************************************************************/
462 static void display_group_info1(struct samr_GroupInfoAll
*info1
)
464 printf("\tGroup Name:\t%s\n", info1
->name
.string
);
465 printf("\tDescription:\t%s\n", info1
->description
.string
);
466 printf("\tGroup Attribute:%d\n", info1
->attributes
);
467 printf("\tNum Members:%d\n", info1
->num_members
);
470 /****************************************************************************
472 ****************************************************************************/
473 static void display_group_info2(struct lsa_String
*info2
)
475 printf("\tGroup Description:%s\n", info2
->string
);
479 /****************************************************************************
481 ****************************************************************************/
482 static void display_group_info3(struct samr_GroupInfoAttributes
*info3
)
484 printf("\tGroup Attribute:%d\n", info3
->attributes
);
488 /****************************************************************************
490 ****************************************************************************/
491 static void display_group_info4(struct lsa_String
*info4
)
493 printf("\tGroup Description:%s\n", info4
->string
);
496 /****************************************************************************
498 ****************************************************************************/
499 static void display_group_info5(struct samr_GroupInfoAll
*info5
)
501 printf("\tGroup Name:\t%s\n", info5
->name
.string
);
502 printf("\tDescription:\t%s\n", info5
->description
.string
);
503 printf("\tGroup Attribute:%d\n", info5
->attributes
);
504 printf("\tNum Members:%d\n", info5
->num_members
);
507 /****************************************************************************
508 display sam sync structure
509 ****************************************************************************/
510 static void display_group_info(union samr_GroupInfo
*info
,
511 enum samr_GroupInfoEnum level
)
515 display_group_info1(&info
->all
);
518 display_group_info2(&info
->name
);
521 display_group_info3(&info
->attributes
);
524 display_group_info4(&info
->description
);
527 display_group_info5(&info
->all2
);
532 /***********************************************************************
533 * Query group information
535 static NTSTATUS
cmd_samr_query_group(struct rpc_pipe_client
*cli
,
537 int argc
, const char **argv
)
539 struct policy_handle connect_pol
, domain_pol
, group_pol
;
540 NTSTATUS status
, result
;
541 enum samr_GroupInfoEnum info_level
= GROUPINFOALL
;
542 uint32_t access_mask
= MAXIMUM_ALLOWED_ACCESS
;
543 union samr_GroupInfo
*group_info
= NULL
;
545 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
547 if ((argc
< 2) || (argc
> 4)) {
548 printf("Usage: %s rid [info level] [access mask]\n", argv
[0]);
552 sscanf(argv
[1], "%i", &group_rid
);
555 info_level
= atoi(argv
[2]);
558 sscanf(argv
[3], "%x", &access_mask
);
560 status
= rpccli_try_samr_connects(cli
, mem_ctx
,
561 MAXIMUM_ALLOWED_ACCESS
,
563 if (!NT_STATUS_IS_OK(status
)) {
567 status
= dcerpc_samr_OpenDomain(b
, mem_ctx
,
569 MAXIMUM_ALLOWED_ACCESS
,
573 if (!NT_STATUS_IS_OK(status
)) {
576 if (!NT_STATUS_IS_OK(result
)) {
581 status
= dcerpc_samr_OpenGroup(b
, mem_ctx
,
587 if (!NT_STATUS_IS_OK(status
)) {
590 if (!NT_STATUS_IS_OK(result
)) {
595 status
= dcerpc_samr_QueryGroupInfo(b
, mem_ctx
,
600 if (!NT_STATUS_IS_OK(status
)) {
603 if (!NT_STATUS_IS_OK(result
)) {
608 display_group_info(group_info
, info_level
);
610 dcerpc_samr_Close(b
, mem_ctx
, &group_pol
, &result
);
611 dcerpc_samr_Close(b
, mem_ctx
, &domain_pol
, &result
);
612 dcerpc_samr_Close(b
, mem_ctx
, &connect_pol
, &result
);
617 /* Query groups a user is a member of */
619 static NTSTATUS
cmd_samr_query_usergroups(struct rpc_pipe_client
*cli
,
621 int argc
, const char **argv
)
623 struct policy_handle connect_pol
,
626 NTSTATUS status
, result
;
628 uint32_t access_mask
= MAXIMUM_ALLOWED_ACCESS
;
630 struct samr_RidWithAttributeArray
*rid_array
= NULL
;
631 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
633 if ((argc
< 2) || (argc
> 3)) {
634 printf("Usage: %s rid [access mask]\n", argv
[0]);
638 sscanf(argv
[1], "%i", &user_rid
);
641 sscanf(argv
[2], "%x", &access_mask
);
643 status
= rpccli_try_samr_connects(cli
, mem_ctx
,
644 MAXIMUM_ALLOWED_ACCESS
,
646 if (!NT_STATUS_IS_OK(status
)) {
650 status
= dcerpc_samr_OpenDomain(b
, mem_ctx
,
652 MAXIMUM_ALLOWED_ACCESS
,
656 if (!NT_STATUS_IS_OK(status
)) {
659 if (!NT_STATUS_IS_OK(result
)) {
664 status
= dcerpc_samr_OpenUser(b
, mem_ctx
,
671 if (!NT_STATUS_IS_OK(status
)) {
674 if (!NT_STATUS_IS_OK(result
)) {
679 status
= dcerpc_samr_GetGroupsForUser(b
, mem_ctx
,
683 if (!NT_STATUS_IS_OK(status
)) {
686 if (!NT_STATUS_IS_OK(result
)) {
691 for (i
= 0; i
< rid_array
->count
; i
++) {
692 printf("\tgroup rid:[0x%x] attr:[0x%x]\n",
693 rid_array
->rids
[i
].rid
,
694 rid_array
->rids
[i
].attributes
);
697 dcerpc_samr_Close(b
, mem_ctx
, &user_pol
, &result
);
698 dcerpc_samr_Close(b
, mem_ctx
, &domain_pol
, &result
);
699 dcerpc_samr_Close(b
, mem_ctx
, &connect_pol
, &result
);
704 /* Query aliases a user is a member of */
706 static NTSTATUS
cmd_samr_query_useraliases(struct rpc_pipe_client
*cli
,
708 int argc
, const char **argv
)
710 struct policy_handle connect_pol
, domain_pol
;
711 NTSTATUS status
, result
;
712 struct dom_sid
*sids
;
714 uint32_t access_mask
= MAXIMUM_ALLOWED_ACCESS
;
716 struct lsa_SidArray sid_array
;
717 struct samr_Ids alias_rids
;
718 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
721 printf("Usage: %s builtin|domain sid1 sid2 ...\n", argv
[0]);
722 return NT_STATUS_INVALID_PARAMETER
;
728 for (i
=2; i
<argc
; i
++) {
729 struct dom_sid tmp_sid
;
730 if (!string_to_sid(&tmp_sid
, argv
[i
])) {
731 printf("%s is not a legal SID\n", argv
[i
]);
732 return NT_STATUS_INVALID_PARAMETER
;
734 result
= add_sid_to_array(mem_ctx
, &tmp_sid
, &sids
, &num_sids
);
735 if (!NT_STATUS_IS_OK(result
)) {
741 sid_array
.sids
= talloc_zero_array(mem_ctx
, struct lsa_SidPtr
, num_sids
);
742 if (sid_array
.sids
== NULL
)
743 return NT_STATUS_NO_MEMORY
;
745 sid_array
.sids
= NULL
;
748 for (i
=0; i
<num_sids
; i
++) {
749 sid_array
.sids
[i
].sid
= dom_sid_dup(mem_ctx
, &sids
[i
]);
750 if (!sid_array
.sids
[i
].sid
) {
751 return NT_STATUS_NO_MEMORY
;
755 sid_array
.num_sids
= num_sids
;
757 status
= rpccli_try_samr_connects(cli
, mem_ctx
,
758 MAXIMUM_ALLOWED_ACCESS
,
760 if (!NT_STATUS_IS_OK(status
)) {
764 status
= get_domain_handle(cli
, mem_ctx
, argv
[1],
769 if (!NT_STATUS_IS_OK(status
)) {
773 status
= dcerpc_samr_GetAliasMembership(b
, mem_ctx
,
778 if (!NT_STATUS_IS_OK(status
)) {
781 if (!NT_STATUS_IS_OK(result
)) {
786 for (i
= 0; i
< alias_rids
.count
; i
++) {
787 printf("\tgroup rid:[0x%x]\n", alias_rids
.ids
[i
]);
790 dcerpc_samr_Close(b
, mem_ctx
, &domain_pol
, &result
);
791 dcerpc_samr_Close(b
, mem_ctx
, &connect_pol
, &result
);
796 /* Query members of a group */
798 static NTSTATUS
cmd_samr_query_groupmem(struct rpc_pipe_client
*cli
,
800 int argc
, const char **argv
)
802 struct policy_handle connect_pol
, domain_pol
, group_pol
;
803 NTSTATUS status
, result
;
805 uint32_t access_mask
= MAXIMUM_ALLOWED_ACCESS
;
807 unsigned int old_timeout
;
808 struct samr_RidAttrArray
*rids
= NULL
;
809 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
811 if ((argc
< 2) || (argc
> 3)) {
812 printf("Usage: %s rid [access mask]\n", argv
[0]);
816 sscanf(argv
[1], "%i", &group_rid
);
819 sscanf(argv
[2], "%x", &access_mask
);
821 status
= rpccli_try_samr_connects(cli
, mem_ctx
,
822 MAXIMUM_ALLOWED_ACCESS
,
824 if (!NT_STATUS_IS_OK(status
)) {
828 status
= dcerpc_samr_OpenDomain(b
, mem_ctx
,
830 MAXIMUM_ALLOWED_ACCESS
,
834 if (!NT_STATUS_IS_OK(status
)) {
837 if (!NT_STATUS_IS_OK(result
)) {
842 status
= dcerpc_samr_OpenGroup(b
, mem_ctx
,
848 if (!NT_STATUS_IS_OK(status
)) {
851 if (!NT_STATUS_IS_OK(result
)) {
856 /* Make sure to wait for our DC's reply */
857 old_timeout
= rpccli_set_timeout(cli
, 30000); /* 30 seconds. */
858 rpccli_set_timeout(cli
, MAX(30000, old_timeout
)); /* At least 30 sec */
860 status
= dcerpc_samr_QueryGroupMember(b
, mem_ctx
,
865 rpccli_set_timeout(cli
, old_timeout
);
867 if (!NT_STATUS_IS_OK(status
)) {
870 if (!NT_STATUS_IS_OK(result
)) {
875 for (i
= 0; i
< rids
->count
; i
++) {
876 printf("\trid:[0x%x] attr:[0x%x]\n", rids
->rids
[i
],
877 rids
->attributes
[i
]);
880 dcerpc_samr_Close(b
, mem_ctx
, &group_pol
, &result
);
881 dcerpc_samr_Close(b
, mem_ctx
, &domain_pol
, &result
);
882 dcerpc_samr_Close(b
, mem_ctx
, &connect_pol
, &result
);
887 /* Enumerate domain users */
889 static NTSTATUS
cmd_samr_enum_dom_users(struct rpc_pipe_client
*cli
,
891 int argc
, const char **argv
)
893 struct policy_handle connect_pol
;
894 struct policy_handle domain_pol
= { 0, };
895 NTSTATUS status
, result
;
896 uint32_t start_idx
, num_dom_users
, i
;
897 struct samr_SamArray
*dom_users
= NULL
;
898 uint32_t access_mask
= MAXIMUM_ALLOWED_ACCESS
;
899 uint32_t acb_mask
= ACB_NORMAL
;
900 uint32_t size
= 0xffff;
901 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
903 if ((argc
< 1) || (argc
> 4)) {
904 printf("Usage: %s [access_mask] [acb_mask] [size]\n", argv
[0]);
909 sscanf(argv
[1], "%x", &access_mask
);
913 sscanf(argv
[2], "%x", &acb_mask
);
917 sscanf(argv
[3], "%x", &size
);
920 /* Get sam policy handle */
922 status
= rpccli_try_samr_connects(cli
, mem_ctx
,
923 MAXIMUM_ALLOWED_ACCESS
,
925 if (!NT_STATUS_IS_OK(status
)) {
929 /* Get domain policy handle */
931 status
= get_domain_handle(cli
, mem_ctx
, "domain",
936 if (!NT_STATUS_IS_OK(status
)) {
940 /* Enumerate domain users */
945 status
= dcerpc_samr_EnumDomainUsers(b
, mem_ctx
,
953 if (!NT_STATUS_IS_OK(status
)) {
956 if (NT_STATUS_IS_OK(result
) ||
957 NT_STATUS_V(result
) == NT_STATUS_V(STATUS_MORE_ENTRIES
)) {
959 for (i
= 0; i
< num_dom_users
; i
++)
960 printf("user:[%s] rid:[0x%x]\n",
961 dom_users
->entries
[i
].name
.string
,
962 dom_users
->entries
[i
].idx
);
965 } while (NT_STATUS_V(result
) == NT_STATUS_V(STATUS_MORE_ENTRIES
));
968 if (is_valid_policy_hnd(&domain_pol
))
969 dcerpc_samr_Close(b
, mem_ctx
, &domain_pol
, &result
);
971 if (is_valid_policy_hnd(&connect_pol
))
972 dcerpc_samr_Close(b
, mem_ctx
, &connect_pol
, &result
);
977 /* Enumerate domain groups */
979 static NTSTATUS
cmd_samr_enum_dom_groups(struct rpc_pipe_client
*cli
,
981 int argc
, const char **argv
)
983 struct policy_handle connect_pol
;
984 struct policy_handle domain_pol
= { 0, };
985 NTSTATUS status
, result
;
986 uint32_t start_idx
, num_dom_groups
, i
;
987 uint32_t access_mask
= MAXIMUM_ALLOWED_ACCESS
;
988 struct samr_SamArray
*dom_groups
= NULL
;
989 uint32_t size
= 0xffff;
990 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
992 if ((argc
< 1) || (argc
> 3)) {
993 printf("Usage: %s [access_mask] [max_size]\n", argv
[0]);
998 sscanf(argv
[1], "%x", &access_mask
);
1002 sscanf(argv
[2], "%x", &size
);
1005 /* Get sam policy handle */
1007 status
= rpccli_try_samr_connects(cli
, mem_ctx
,
1008 MAXIMUM_ALLOWED_ACCESS
,
1010 if (!NT_STATUS_IS_OK(status
)) {
1014 /* Get domain policy handle */
1016 status
= get_domain_handle(cli
, mem_ctx
, "domain",
1021 if (!NT_STATUS_IS_OK(status
)) {
1025 /* Enumerate domain groups */
1030 status
= dcerpc_samr_EnumDomainGroups(b
, mem_ctx
,
1037 if (!NT_STATUS_IS_OK(status
)) {
1040 if (NT_STATUS_IS_OK(result
) ||
1041 NT_STATUS_V(result
) == NT_STATUS_V(STATUS_MORE_ENTRIES
)) {
1043 for (i
= 0; i
< num_dom_groups
; i
++)
1044 printf("group:[%s] rid:[0x%x]\n",
1045 dom_groups
->entries
[i
].name
.string
,
1046 dom_groups
->entries
[i
].idx
);
1049 } while (NT_STATUS_V(result
) == NT_STATUS_V(STATUS_MORE_ENTRIES
));
1052 if (is_valid_policy_hnd(&domain_pol
))
1053 dcerpc_samr_Close(b
, mem_ctx
, &domain_pol
, &result
);
1055 if (is_valid_policy_hnd(&connect_pol
))
1056 dcerpc_samr_Close(b
, mem_ctx
, &connect_pol
, &result
);
1061 /* Enumerate alias groups */
1063 static NTSTATUS
cmd_samr_enum_als_groups(struct rpc_pipe_client
*cli
,
1064 TALLOC_CTX
*mem_ctx
,
1065 int argc
, const char **argv
)
1067 struct policy_handle connect_pol
;
1068 struct policy_handle domain_pol
= { 0, };
1069 NTSTATUS status
, result
;
1070 uint32_t start_idx
, num_als_groups
, i
;
1071 uint32_t access_mask
= MAXIMUM_ALLOWED_ACCESS
;
1072 struct samr_SamArray
*als_groups
= NULL
;
1073 uint32_t size
= 0xffff;
1074 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
1076 if ((argc
< 2) || (argc
> 4)) {
1077 printf("Usage: %s builtin|domain [access mask] [max_size]\n", argv
[0]);
1078 return NT_STATUS_OK
;
1082 sscanf(argv
[2], "%x", &access_mask
);
1086 sscanf(argv
[3], "%x", &size
);
1089 /* Get sam policy handle */
1091 status
= rpccli_try_samr_connects(cli
, mem_ctx
,
1092 MAXIMUM_ALLOWED_ACCESS
,
1094 if (!NT_STATUS_IS_OK(status
)) {
1098 /* Get domain policy handle */
1100 status
= get_domain_handle(cli
, mem_ctx
, argv
[1],
1105 if (!NT_STATUS_IS_OK(status
)) {
1109 /* Enumerate alias groups */
1114 status
= dcerpc_samr_EnumDomainAliases(b
, mem_ctx
,
1121 if (!NT_STATUS_IS_OK(status
)) {
1124 if (NT_STATUS_IS_OK(result
) ||
1125 NT_STATUS_V(result
) == NT_STATUS_V(STATUS_MORE_ENTRIES
)) {
1127 for (i
= 0; i
< num_als_groups
; i
++)
1128 printf("group:[%s] rid:[0x%x]\n",
1129 als_groups
->entries
[i
].name
.string
,
1130 als_groups
->entries
[i
].idx
);
1132 } while (NT_STATUS_V(result
) == NT_STATUS_V(STATUS_MORE_ENTRIES
));
1135 if (is_valid_policy_hnd(&domain_pol
))
1136 dcerpc_samr_Close(b
, mem_ctx
, &domain_pol
, &result
);
1138 if (is_valid_policy_hnd(&connect_pol
))
1139 dcerpc_samr_Close(b
, mem_ctx
, &connect_pol
, &result
);
1144 /* Enumerate domains */
1146 static NTSTATUS
cmd_samr_enum_domains(struct rpc_pipe_client
*cli
,
1147 TALLOC_CTX
*mem_ctx
,
1148 int argc
, const char **argv
)
1150 struct policy_handle connect_pol
;
1151 NTSTATUS status
, result
;
1152 uint32_t start_idx
, size
, num_entries
, i
;
1153 uint32_t access_mask
= SEC_FLAG_MAXIMUM_ALLOWED
;
1154 struct samr_SamArray
*sam
= NULL
;
1155 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
1157 if ((argc
< 1) || (argc
> 2)) {
1158 printf("Usage: %s [access mask]\n", argv
[0]);
1159 return NT_STATUS_OK
;
1163 sscanf(argv
[1], "%x", &access_mask
);
1166 /* Get sam policy handle */
1168 status
= rpccli_try_samr_connects(cli
, mem_ctx
,
1171 if (!NT_STATUS_IS_OK(status
)) {
1175 /* Enumerate alias groups */
1181 status
= dcerpc_samr_EnumDomains(b
, mem_ctx
,
1188 if (!NT_STATUS_IS_OK(status
)) {
1191 if (NT_STATUS_IS_OK(result
) ||
1192 NT_STATUS_V(result
) == NT_STATUS_V(STATUS_MORE_ENTRIES
)) {
1194 for (i
= 0; i
< num_entries
; i
++)
1195 printf("name:[%s] idx:[0x%x]\n",
1196 sam
->entries
[i
].name
.string
,
1197 sam
->entries
[i
].idx
);
1199 } while (NT_STATUS_V(result
) == NT_STATUS_V(STATUS_MORE_ENTRIES
));
1202 if (is_valid_policy_hnd(&connect_pol
)) {
1203 dcerpc_samr_Close(b
, mem_ctx
, &connect_pol
, &result
);
1210 /* Query alias membership */
1212 static NTSTATUS
cmd_samr_query_aliasmem(struct rpc_pipe_client
*cli
,
1213 TALLOC_CTX
*mem_ctx
,
1214 int argc
, const char **argv
)
1216 struct policy_handle connect_pol
, domain_pol
, alias_pol
;
1217 NTSTATUS status
, result
;
1218 uint32_t alias_rid
, i
;
1219 uint32_t access_mask
= MAXIMUM_ALLOWED_ACCESS
;
1220 struct lsa_SidArray sid_array
;
1221 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
1223 if ((argc
< 3) || (argc
> 4)) {
1224 printf("Usage: %s builtin|domain rid [access mask]\n", argv
[0]);
1225 return NT_STATUS_OK
;
1228 sscanf(argv
[2], "%i", &alias_rid
);
1231 sscanf(argv
[3], "%x", &access_mask
);
1233 /* Open SAMR handle */
1235 status
= rpccli_try_samr_connects(cli
, mem_ctx
,
1236 MAXIMUM_ALLOWED_ACCESS
,
1238 if (!NT_STATUS_IS_OK(status
)) {
1242 /* Open handle on domain */
1244 status
= get_domain_handle(cli
, mem_ctx
, argv
[1],
1246 MAXIMUM_ALLOWED_ACCESS
,
1249 if (!NT_STATUS_IS_OK(status
)) {
1253 /* Open handle on alias */
1255 status
= dcerpc_samr_OpenAlias(b
, mem_ctx
,
1261 if (!NT_STATUS_IS_OK(status
)) {
1264 if (!NT_STATUS_IS_OK(result
)) {
1269 status
= dcerpc_samr_GetMembersInAlias(b
, mem_ctx
,
1273 if (!NT_STATUS_IS_OK(status
)) {
1276 if (!NT_STATUS_IS_OK(result
)) {
1281 for (i
= 0; i
< sid_array
.num_sids
; i
++) {
1284 sid_to_fstring(sid_str
, sid_array
.sids
[i
].sid
);
1285 printf("\tsid:[%s]\n", sid_str
);
1288 dcerpc_samr_Close(b
, mem_ctx
, &alias_pol
, &result
);
1289 dcerpc_samr_Close(b
, mem_ctx
, &domain_pol
, &result
);
1290 dcerpc_samr_Close(b
, mem_ctx
, &connect_pol
, &result
);
1295 /* Query alias info */
1297 static NTSTATUS
cmd_samr_query_aliasinfo(struct rpc_pipe_client
*cli
,
1298 TALLOC_CTX
*mem_ctx
,
1299 int argc
, const char **argv
)
1301 struct policy_handle connect_pol
, domain_pol
, alias_pol
;
1302 NTSTATUS status
, result
;
1304 uint32_t access_mask
= SEC_FLAG_MAXIMUM_ALLOWED
;
1305 union samr_AliasInfo
*info
= NULL
;
1306 enum samr_AliasInfoEnum level
= ALIASINFOALL
;
1307 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
1309 if ((argc
< 3) || (argc
> 4)) {
1310 printf("Usage: %s builtin|domain rid [level] [access mask]\n",
1312 return NT_STATUS_OK
;
1315 sscanf(argv
[2], "%i", &alias_rid
);
1318 level
= atoi(argv
[3]);
1322 sscanf(argv
[4], "%x", &access_mask
);
1325 /* Open SAMR handle */
1327 status
= rpccli_try_samr_connects(cli
, mem_ctx
,
1328 SEC_FLAG_MAXIMUM_ALLOWED
,
1330 if (!NT_STATUS_IS_OK(status
)) {
1334 /* Open handle on domain */
1336 status
= get_domain_handle(cli
, mem_ctx
, argv
[1],
1338 SEC_FLAG_MAXIMUM_ALLOWED
,
1341 if (!NT_STATUS_IS_OK(status
)) {
1345 /* Open handle on alias */
1347 status
= dcerpc_samr_OpenAlias(b
, mem_ctx
,
1353 if (!NT_STATUS_IS_OK(status
)) {
1356 if (!NT_STATUS_IS_OK(result
)) {
1361 status
= dcerpc_samr_QueryAliasInfo(b
, mem_ctx
,
1366 if (!NT_STATUS_IS_OK(status
)) {
1369 if (!NT_STATUS_IS_OK(result
)) {
1376 printf("Name: %s\n", info
->all
.name
.string
);
1377 printf("Description: %s\n", info
->all
.description
.string
);
1378 printf("Num Members: %d\n", info
->all
.num_members
);
1381 printf("Name: %s\n", info
->name
.string
);
1383 case ALIASINFODESCRIPTION
:
1384 printf("Description: %s\n", info
->description
.string
);
1390 dcerpc_samr_Close(b
, mem_ctx
, &alias_pol
, &result
);
1391 dcerpc_samr_Close(b
, mem_ctx
, &domain_pol
, &result
);
1392 dcerpc_samr_Close(b
, mem_ctx
, &connect_pol
, &result
);
1398 /* Query delete an alias membership */
1400 static NTSTATUS
cmd_samr_delete_alias(struct rpc_pipe_client
*cli
,
1401 TALLOC_CTX
*mem_ctx
,
1402 int argc
, const char **argv
)
1404 struct policy_handle connect_pol
, domain_pol
, alias_pol
;
1405 NTSTATUS status
, result
;
1407 uint32_t access_mask
= MAXIMUM_ALLOWED_ACCESS
;
1408 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
1411 printf("Usage: %s builtin|domain [rid|name]\n", argv
[0]);
1412 return NT_STATUS_OK
;
1415 alias_rid
= strtoul(argv
[2], NULL
, 10);
1417 /* Open SAMR handle */
1419 status
= rpccli_try_samr_connects(cli
, mem_ctx
,
1420 MAXIMUM_ALLOWED_ACCESS
,
1422 if (!NT_STATUS_IS_OK(status
)) {
1426 /* Open handle on domain */
1428 status
= get_domain_handle(cli
, mem_ctx
, argv
[1],
1430 MAXIMUM_ALLOWED_ACCESS
,
1433 if (!NT_STATUS_IS_OK(status
)) {
1437 /* Open handle on alias */
1439 status
= dcerpc_samr_OpenAlias(b
, mem_ctx
,
1445 if (!NT_STATUS_IS_OK(status
)) {
1448 if (!NT_STATUS_IS_OK(result
) && (alias_rid
== 0)) {
1449 /* Probably this was a user name, try lookupnames */
1450 struct samr_Ids rids
, types
;
1451 struct lsa_String lsa_acct_name
;
1453 init_lsa_String(&lsa_acct_name
, argv
[2]);
1455 status
= dcerpc_samr_LookupNames(b
, mem_ctx
,
1462 if (!NT_STATUS_IS_OK(status
)) {
1465 if (NT_STATUS_IS_OK(result
)) {
1466 if (rids
.count
!= 1) {
1467 status
= NT_STATUS_INVALID_NETWORK_RESPONSE
;
1470 if (types
.count
!= 1) {
1471 status
= NT_STATUS_INVALID_NETWORK_RESPONSE
;
1475 status
= dcerpc_samr_OpenAlias(b
, mem_ctx
,
1481 if (!NT_STATUS_IS_OK(status
)) {
1487 status
= dcerpc_samr_DeleteDomAlias(b
, mem_ctx
,
1490 if (!NT_STATUS_IS_OK(status
)) {
1493 if (!NT_STATUS_IS_OK(result
)) {
1498 dcerpc_samr_Close(b
, mem_ctx
, &domain_pol
, &result
);
1499 dcerpc_samr_Close(b
, mem_ctx
, &connect_pol
, &result
);
1504 /* Query display info */
1506 static NTSTATUS
cmd_samr_query_dispinfo_internal(struct rpc_pipe_client
*cli
,
1507 TALLOC_CTX
*mem_ctx
,
1508 int argc
, const char **argv
,
1511 struct policy_handle connect_pol
, domain_pol
;
1512 NTSTATUS status
, result
;
1513 uint32_t start_idx
=0, max_entries
=250, max_size
= 0xffff, num_entries
= 0, i
;
1514 uint32_t access_mask
= MAXIMUM_ALLOWED_ACCESS
;
1515 uint32_t info_level
= 1;
1516 union samr_DispInfo info
;
1518 bool got_params
= False
; /* Use get_query_dispinfo_params() or not? */
1519 uint32_t total_size
, returned_size
;
1520 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
1523 printf("Usage: %s [info level] [start index] [max entries] [max size] [access mask]\n", argv
[0]);
1524 return NT_STATUS_OK
;
1528 sscanf(argv
[1], "%i", &info_level
);
1531 sscanf(argv
[2], "%i", &start_idx
);
1534 sscanf(argv
[3], "%i", &max_entries
);
1539 sscanf(argv
[4], "%i", &max_size
);
1544 sscanf(argv
[5], "%x", &access_mask
);
1546 /* Get sam policy handle */
1548 status
= rpccli_try_samr_connects(cli
, mem_ctx
,
1549 MAXIMUM_ALLOWED_ACCESS
,
1551 if (!NT_STATUS_IS_OK(status
)) {
1555 /* Get domain policy handle */
1557 status
= dcerpc_samr_OpenDomain(b
, mem_ctx
,
1563 if (!NT_STATUS_IS_OK(status
)) {
1566 if (!NT_STATUS_IS_OK(result
)) {
1571 /* Query display info */
1576 dcerpc_get_query_dispinfo_params(
1577 loop_count
, &max_entries
, &max_size
);
1580 case NDR_SAMR_QUERYDISPLAYINFO
:
1581 status
= dcerpc_samr_QueryDisplayInfo(b
, mem_ctx
,
1592 case NDR_SAMR_QUERYDISPLAYINFO2
:
1593 status
= dcerpc_samr_QueryDisplayInfo2(b
, mem_ctx
,
1605 case NDR_SAMR_QUERYDISPLAYINFO3
:
1606 status
= dcerpc_samr_QueryDisplayInfo3(b
, mem_ctx
,
1619 return NT_STATUS_INVALID_PARAMETER
;
1622 if (!NT_STATUS_IS_OK(status
)) {
1626 if (!NT_STATUS_IS_OK(result
) &&
1627 !NT_STATUS_EQUAL(result
, NT_STATUS_NO_MORE_ENTRIES
) &&
1628 !NT_STATUS_EQUAL(result
, STATUS_MORE_ENTRIES
)) {
1634 switch (info_level
) {
1636 num_entries
= info
.info1
.count
;
1639 num_entries
= info
.info2
.count
;
1642 num_entries
= info
.info3
.count
;
1645 num_entries
= info
.info4
.count
;
1648 num_entries
= info
.info5
.count
;
1654 start_idx
+= num_entries
;
1656 if (num_entries
== 0)
1659 for (i
= 0; i
< num_entries
; i
++) {
1660 switch (info_level
) {
1662 display_sam_info_1(&info
.info1
.entries
[i
]);
1665 display_sam_info_2(&info
.info2
.entries
[i
]);
1668 display_sam_info_3(&info
.info3
.entries
[i
]);
1671 display_sam_info_4(&info
.info4
.entries
[i
]);
1674 display_sam_info_5(&info
.info5
.entries
[i
]);
1678 } while ( NT_STATUS_EQUAL(result
, STATUS_MORE_ENTRIES
));
1680 dcerpc_samr_Close(b
, mem_ctx
, &domain_pol
, &result
);
1681 dcerpc_samr_Close(b
, mem_ctx
, &connect_pol
, &result
);
1686 static NTSTATUS
cmd_samr_query_dispinfo(struct rpc_pipe_client
*cli
,
1687 TALLOC_CTX
*mem_ctx
,
1688 int argc
, const char **argv
)
1690 return cmd_samr_query_dispinfo_internal(cli
, mem_ctx
, argc
, argv
,
1691 NDR_SAMR_QUERYDISPLAYINFO
);
1694 static NTSTATUS
cmd_samr_query_dispinfo2(struct rpc_pipe_client
*cli
,
1695 TALLOC_CTX
*mem_ctx
,
1696 int argc
, const char **argv
)
1698 return cmd_samr_query_dispinfo_internal(cli
, mem_ctx
, argc
, argv
,
1699 NDR_SAMR_QUERYDISPLAYINFO2
);
1702 static NTSTATUS
cmd_samr_query_dispinfo3(struct rpc_pipe_client
*cli
,
1703 TALLOC_CTX
*mem_ctx
,
1704 int argc
, const char **argv
)
1706 return cmd_samr_query_dispinfo_internal(cli
, mem_ctx
, argc
, argv
,
1707 NDR_SAMR_QUERYDISPLAYINFO3
);
1710 /* Query domain info */
1712 static NTSTATUS
cmd_samr_query_dominfo(struct rpc_pipe_client
*cli
,
1713 TALLOC_CTX
*mem_ctx
,
1714 int argc
, const char **argv
)
1716 struct policy_handle connect_pol
, domain_pol
;
1717 NTSTATUS status
, result
;
1718 uint32_t switch_level
= 2;
1719 uint32_t access_mask
= MAXIMUM_ALLOWED_ACCESS
;
1720 union samr_DomainInfo
*info
= NULL
;
1721 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
1724 printf("Usage: %s [info level] [access mask]\n", argv
[0]);
1725 return NT_STATUS_OK
;
1729 sscanf(argv
[1], "%i", &switch_level
);
1732 sscanf(argv
[2], "%x", &access_mask
);
1734 /* Get sam policy handle */
1736 status
= rpccli_try_samr_connects(cli
, mem_ctx
,
1737 MAXIMUM_ALLOWED_ACCESS
,
1739 if (!NT_STATUS_IS_OK(status
)) {
1743 /* Get domain policy handle */
1745 status
= dcerpc_samr_OpenDomain(b
, mem_ctx
,
1751 if (!NT_STATUS_IS_OK(status
)) {
1754 if (!NT_STATUS_IS_OK(result
)) {
1759 /* Query domain info */
1761 status
= dcerpc_samr_QueryDomainInfo(b
, mem_ctx
,
1766 if (!NT_STATUS_IS_OK(status
)) {
1769 if (!NT_STATUS_IS_OK(result
)) {
1774 /* Display domain info */
1776 switch (switch_level
) {
1778 display_sam_dom_info_1(&info
->info1
);
1781 display_sam_dom_info_2(&info
->general
);
1784 display_sam_dom_info_3(&info
->info3
);
1787 display_sam_dom_info_4(&info
->oem
);
1790 display_sam_dom_info_5(&info
->info5
);
1793 display_sam_dom_info_6(&info
->info6
);
1796 display_sam_dom_info_7(&info
->info7
);
1799 display_sam_dom_info_8(&info
->info8
);
1802 display_sam_dom_info_9(&info
->info9
);
1805 display_sam_dom_info_12(&info
->info12
);
1808 display_sam_dom_info_13(&info
->info13
);
1812 printf("cannot display domain info for switch value %d\n",
1819 dcerpc_samr_Close(b
, mem_ctx
, &domain_pol
, &result
);
1820 dcerpc_samr_Close(b
, mem_ctx
, &connect_pol
, &result
);
1824 /* Create domain user */
1826 static NTSTATUS
cmd_samr_create_dom_user(struct rpc_pipe_client
*cli
,
1827 TALLOC_CTX
*mem_ctx
,
1828 int argc
, const char **argv
)
1830 struct policy_handle connect_pol
, domain_pol
, user_pol
;
1831 NTSTATUS status
, result
;
1832 struct lsa_String acct_name
;
1834 uint32_t acct_flags
, user_rid
;
1835 uint32_t access_mask
= MAXIMUM_ALLOWED_ACCESS
;
1836 uint32_t access_granted
= 0;
1837 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
1839 if ((argc
< 2) || (argc
> 3)) {
1840 printf("Usage: %s username [access mask]\n", argv
[0]);
1841 return NT_STATUS_OK
;
1844 init_lsa_String(&acct_name
, argv
[1]);
1847 sscanf(argv
[2], "%x", &access_mask
);
1849 /* Get sam policy handle */
1851 status
= rpccli_try_samr_connects(cli
, mem_ctx
,
1852 MAXIMUM_ALLOWED_ACCESS
,
1854 if (!NT_STATUS_IS_OK(status
)) {
1858 /* Get domain policy handle */
1860 status
= dcerpc_samr_OpenDomain(b
, mem_ctx
,
1866 if (!NT_STATUS_IS_OK(status
)) {
1869 if (!NT_STATUS_IS_OK(result
)) {
1874 /* Create domain user */
1876 acb_info
= ACB_NORMAL
;
1877 acct_flags
= SEC_GENERIC_READ
| SEC_GENERIC_WRITE
| SEC_GENERIC_EXECUTE
|
1878 SEC_STD_WRITE_DAC
| SEC_STD_DELETE
|
1879 SAMR_USER_ACCESS_SET_PASSWORD
|
1880 SAMR_USER_ACCESS_GET_ATTRIBUTES
|
1881 SAMR_USER_ACCESS_SET_ATTRIBUTES
;
1883 status
= dcerpc_samr_CreateUser2(b
, mem_ctx
,
1892 if (!NT_STATUS_IS_OK(status
)) {
1895 if (!NT_STATUS_IS_OK(result
)) {
1900 status
= dcerpc_samr_Close(b
, mem_ctx
, &user_pol
, &result
);
1901 if (!NT_STATUS_IS_OK(status
)) goto done
;
1903 status
= dcerpc_samr_Close(b
, mem_ctx
, &domain_pol
, &result
);
1904 if (!NT_STATUS_IS_OK(status
)) goto done
;
1906 status
= dcerpc_samr_Close(b
, mem_ctx
, &connect_pol
, &result
);
1907 if (!NT_STATUS_IS_OK(status
)) goto done
;
1913 /* Create domain group */
1915 static NTSTATUS
cmd_samr_create_dom_group(struct rpc_pipe_client
*cli
,
1916 TALLOC_CTX
*mem_ctx
,
1917 int argc
, const char **argv
)
1919 struct policy_handle connect_pol
, domain_pol
, group_pol
;
1920 NTSTATUS status
, result
;
1921 struct lsa_String grp_name
;
1922 uint32_t access_mask
= MAXIMUM_ALLOWED_ACCESS
;
1924 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
1926 if ((argc
< 2) || (argc
> 3)) {
1927 printf("Usage: %s groupname [access mask]\n", argv
[0]);
1928 return NT_STATUS_OK
;
1931 init_lsa_String(&grp_name
, argv
[1]);
1934 sscanf(argv
[2], "%x", &access_mask
);
1936 /* Get sam policy handle */
1938 status
= rpccli_try_samr_connects(cli
, mem_ctx
,
1939 MAXIMUM_ALLOWED_ACCESS
,
1941 if (!NT_STATUS_IS_OK(status
)) {
1945 /* Get domain policy handle */
1947 status
= dcerpc_samr_OpenDomain(b
, mem_ctx
,
1953 if (!NT_STATUS_IS_OK(status
)) {
1956 if (!NT_STATUS_IS_OK(result
)) {
1961 /* Create domain user */
1962 status
= dcerpc_samr_CreateDomainGroup(b
, mem_ctx
,
1965 MAXIMUM_ALLOWED_ACCESS
,
1969 if (!NT_STATUS_IS_OK(status
)) {
1972 if (!NT_STATUS_IS_OK(result
)) {
1977 status
= dcerpc_samr_Close(b
, mem_ctx
, &group_pol
, &result
);
1978 if (!NT_STATUS_IS_OK(status
)) goto done
;
1980 status
= dcerpc_samr_Close(b
, mem_ctx
, &domain_pol
, &result
);
1981 if (!NT_STATUS_IS_OK(status
)) goto done
;
1983 status
= dcerpc_samr_Close(b
, mem_ctx
, &connect_pol
, &result
);
1984 if (!NT_STATUS_IS_OK(status
)) goto done
;
1990 /* Create domain alias */
1992 static NTSTATUS
cmd_samr_create_dom_alias(struct rpc_pipe_client
*cli
,
1993 TALLOC_CTX
*mem_ctx
,
1994 int argc
, const char **argv
)
1996 struct policy_handle connect_pol
, domain_pol
, alias_pol
;
1997 NTSTATUS status
, result
;
1998 struct lsa_String alias_name
;
1999 uint32_t access_mask
= MAXIMUM_ALLOWED_ACCESS
;
2001 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
2003 if ((argc
< 2) || (argc
> 3)) {
2004 printf("Usage: %s aliasname [access mask]\n", argv
[0]);
2005 return NT_STATUS_OK
;
2008 init_lsa_String(&alias_name
, argv
[1]);
2011 sscanf(argv
[2], "%x", &access_mask
);
2013 /* Get sam policy handle */
2015 status
= rpccli_try_samr_connects(cli
, mem_ctx
,
2016 MAXIMUM_ALLOWED_ACCESS
,
2018 if (!NT_STATUS_IS_OK(status
)) {
2022 /* Get domain policy handle */
2024 status
= dcerpc_samr_OpenDomain(b
, mem_ctx
,
2030 if (!NT_STATUS_IS_OK(status
)) {
2033 if (!NT_STATUS_IS_OK(result
)) {
2038 /* Create domain user */
2040 status
= dcerpc_samr_CreateDomAlias(b
, mem_ctx
,
2043 MAXIMUM_ALLOWED_ACCESS
,
2047 if (!NT_STATUS_IS_OK(status
)) {
2050 if (!NT_STATUS_IS_OK(result
)) {
2056 status
= dcerpc_samr_Close(b
, mem_ctx
, &alias_pol
, &result
);
2057 if (!NT_STATUS_IS_OK(status
)) goto done
;
2059 status
= dcerpc_samr_Close(b
, mem_ctx
, &domain_pol
, &result
);
2060 if (!NT_STATUS_IS_OK(status
)) goto done
;
2062 status
= dcerpc_samr_Close(b
, mem_ctx
, &connect_pol
, &result
);
2063 if (!NT_STATUS_IS_OK(status
)) goto done
;
2069 /* Lookup sam names */
2071 static NTSTATUS
cmd_samr_lookup_names(struct rpc_pipe_client
*cli
,
2072 TALLOC_CTX
*mem_ctx
,
2073 int argc
, const char **argv
)
2075 NTSTATUS status
, result
;
2076 struct policy_handle connect_pol
, domain_pol
;
2078 struct samr_Ids rids
, name_types
;
2080 struct lsa_String
*names
= NULL
;
2081 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
2084 printf("Usage: %s domain|builtin name1 [name2 [name3] [...]]\n", argv
[0]);
2085 printf("check on the domain SID: S-1-5-21-x-y-z\n");
2086 printf("or check on the builtin SID: S-1-5-32\n");
2087 return NT_STATUS_OK
;
2090 /* Get sam policy and domain handles */
2092 status
= rpccli_try_samr_connects(cli
, mem_ctx
,
2093 MAXIMUM_ALLOWED_ACCESS
,
2095 if (!NT_STATUS_IS_OK(status
)) {
2099 status
= get_domain_handle(cli
, mem_ctx
, argv
[1],
2101 MAXIMUM_ALLOWED_ACCESS
,
2104 if (!NT_STATUS_IS_OK(status
)) {
2110 num_names
= argc
- 2;
2112 if ((names
= talloc_array(mem_ctx
, struct lsa_String
, num_names
)) == NULL
) {
2113 dcerpc_samr_Close(b
, mem_ctx
, &domain_pol
, &result
);
2114 dcerpc_samr_Close(b
, mem_ctx
, &connect_pol
, &result
);
2115 status
= NT_STATUS_NO_MEMORY
;
2119 for (i
= 0; i
< num_names
; i
++) {
2120 init_lsa_String(&names
[i
], argv
[i
+ 2]);
2123 status
= dcerpc_samr_LookupNames(b
, mem_ctx
,
2130 if (!NT_STATUS_IS_OK(status
)) {
2133 if (!NT_STATUS_IS_OK(result
)) {
2137 if (rids
.count
!= num_names
) {
2138 status
= NT_STATUS_INVALID_NETWORK_RESPONSE
;
2141 if (name_types
.count
!= num_names
) {
2142 status
= NT_STATUS_INVALID_NETWORK_RESPONSE
;
2146 /* Display results */
2148 for (i
= 0; i
< num_names
; i
++)
2149 printf("name %s: 0x%x (%d)\n", names
[i
].string
, rids
.ids
[i
],
2152 dcerpc_samr_Close(b
, mem_ctx
, &domain_pol
, &result
);
2153 dcerpc_samr_Close(b
, mem_ctx
, &connect_pol
, &result
);
2158 /* Lookup sam rids */
2160 static NTSTATUS
cmd_samr_lookup_rids(struct rpc_pipe_client
*cli
,
2161 TALLOC_CTX
*mem_ctx
,
2162 int argc
, const char **argv
)
2164 NTSTATUS status
, result
;
2165 struct policy_handle connect_pol
, domain_pol
;
2166 uint32_t num_rids
, *rids
;
2167 struct lsa_Strings names
;
2168 struct samr_Ids types
;
2169 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
2174 printf("Usage: %s domain|builtin rid1 [rid2 [rid3] [...]]\n", argv
[0]);
2175 return NT_STATUS_OK
;
2178 /* Get sam policy and domain handles */
2180 status
= rpccli_try_samr_connects(cli
, mem_ctx
,
2181 MAXIMUM_ALLOWED_ACCESS
,
2183 if (!NT_STATUS_IS_OK(status
)) {
2187 status
= get_domain_handle(cli
, mem_ctx
, argv
[1],
2189 MAXIMUM_ALLOWED_ACCESS
,
2192 if (!NT_STATUS_IS_OK(status
)) {
2198 num_rids
= argc
- 2;
2200 if ((rids
= talloc_array(mem_ctx
, uint32_t, num_rids
)) == NULL
) {
2201 dcerpc_samr_Close(b
, mem_ctx
, &domain_pol
, &result
);
2202 dcerpc_samr_Close(b
, mem_ctx
, &connect_pol
, &result
);
2203 status
= NT_STATUS_NO_MEMORY
;
2207 for (i
= 0; i
< argc
- 2; i
++)
2208 sscanf(argv
[i
+ 2], "%i", &rids
[i
]);
2210 status
= dcerpc_samr_LookupRids(b
, mem_ctx
,
2217 if (!NT_STATUS_IS_OK(status
)) {
2221 if (!NT_STATUS_IS_OK(result
) &&
2222 !NT_STATUS_EQUAL(result
, STATUS_SOME_UNMAPPED
))
2225 /* Display results */
2226 if (num_rids
!= names
.count
) {
2227 status
= NT_STATUS_INVALID_NETWORK_RESPONSE
;
2230 if (num_rids
!= types
.count
) {
2231 status
= NT_STATUS_INVALID_NETWORK_RESPONSE
;
2235 for (i
= 0; i
< num_rids
; i
++) {
2236 printf("rid 0x%x: %s (%d)\n",
2237 rids
[i
], names
.names
[i
].string
, types
.ids
[i
]);
2240 dcerpc_samr_Close(b
, mem_ctx
, &domain_pol
, &result
);
2241 dcerpc_samr_Close(b
, mem_ctx
, &connect_pol
, &result
);
2246 /* Delete domain group */
2248 static NTSTATUS
cmd_samr_delete_dom_group(struct rpc_pipe_client
*cli
,
2249 TALLOC_CTX
*mem_ctx
,
2250 int argc
, const char **argv
)
2252 NTSTATUS status
, result
;
2253 struct policy_handle connect_pol
, domain_pol
, group_pol
;
2254 uint32_t access_mask
= MAXIMUM_ALLOWED_ACCESS
;
2255 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
2257 if ((argc
< 2) || (argc
> 3)) {
2258 printf("Usage: %s groupname\n", argv
[0]);
2259 return NT_STATUS_OK
;
2263 sscanf(argv
[2], "%x", &access_mask
);
2265 /* Get sam policy and domain handles */
2267 status
= rpccli_try_samr_connects(cli
, mem_ctx
,
2268 MAXIMUM_ALLOWED_ACCESS
,
2270 if (!NT_STATUS_IS_OK(status
)) {
2274 status
= dcerpc_samr_OpenDomain(b
, mem_ctx
,
2276 MAXIMUM_ALLOWED_ACCESS
,
2280 if (!NT_STATUS_IS_OK(status
)) {
2283 if (!NT_STATUS_IS_OK(result
)) {
2288 /* Get handle on group */
2291 struct samr_Ids group_rids
, name_types
;
2292 struct lsa_String lsa_acct_name
;
2294 init_lsa_String(&lsa_acct_name
, argv
[1]);
2296 status
= dcerpc_samr_LookupNames(b
, mem_ctx
,
2303 if (!NT_STATUS_IS_OK(status
)) {
2306 if (!NT_STATUS_IS_OK(result
)) {
2310 if (group_rids
.count
!= 1) {
2311 status
= NT_STATUS_INVALID_NETWORK_RESPONSE
;
2314 if (name_types
.count
!= 1) {
2315 status
= NT_STATUS_INVALID_NETWORK_RESPONSE
;
2319 status
= dcerpc_samr_OpenGroup(b
, mem_ctx
,
2325 if (!NT_STATUS_IS_OK(status
)) {
2328 if (!NT_STATUS_IS_OK(result
)) {
2336 status
= dcerpc_samr_DeleteDomainGroup(b
, mem_ctx
,
2339 if (!NT_STATUS_IS_OK(status
)) {
2342 if (!NT_STATUS_IS_OK(result
)) {
2347 /* Display results */
2349 dcerpc_samr_Close(b
, mem_ctx
, &group_pol
, &result
);
2350 dcerpc_samr_Close(b
, mem_ctx
, &domain_pol
, &result
);
2351 dcerpc_samr_Close(b
, mem_ctx
, &connect_pol
, &result
);
2357 /* Delete domain user */
2359 static NTSTATUS
cmd_samr_delete_dom_user(struct rpc_pipe_client
*cli
,
2360 TALLOC_CTX
*mem_ctx
,
2361 int argc
, const char **argv
)
2363 NTSTATUS status
, result
;
2364 struct policy_handle connect_pol
, domain_pol
, user_pol
;
2365 uint32_t access_mask
= MAXIMUM_ALLOWED_ACCESS
;
2366 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
2368 if ((argc
< 2) || (argc
> 3)) {
2369 printf("Usage: %s username\n", argv
[0]);
2370 return NT_STATUS_OK
;
2374 sscanf(argv
[2], "%x", &access_mask
);
2376 /* Get sam policy and domain handles */
2378 status
= rpccli_try_samr_connects(cli
, mem_ctx
,
2379 MAXIMUM_ALLOWED_ACCESS
,
2381 if (!NT_STATUS_IS_OK(status
)) {
2385 status
= dcerpc_samr_OpenDomain(b
, mem_ctx
,
2387 MAXIMUM_ALLOWED_ACCESS
,
2391 if (!NT_STATUS_IS_OK(status
)) {
2394 if (!NT_STATUS_IS_OK(result
)) {
2399 /* Get handle on user */
2402 struct samr_Ids user_rids
, name_types
;
2403 struct lsa_String lsa_acct_name
;
2405 init_lsa_String(&lsa_acct_name
, argv
[1]);
2407 status
= dcerpc_samr_LookupNames(b
, mem_ctx
,
2414 if (!NT_STATUS_IS_OK(status
)) {
2417 if (!NT_STATUS_IS_OK(result
)) {
2421 if (user_rids
.count
!= 1) {
2422 status
= NT_STATUS_INVALID_NETWORK_RESPONSE
;
2425 if (name_types
.count
!= 1) {
2426 status
= NT_STATUS_INVALID_NETWORK_RESPONSE
;
2430 status
= dcerpc_samr_OpenUser(b
, mem_ctx
,
2436 if (!NT_STATUS_IS_OK(status
)) {
2439 if (!NT_STATUS_IS_OK(result
)) {
2447 status
= dcerpc_samr_DeleteUser(b
, mem_ctx
,
2450 if (!NT_STATUS_IS_OK(status
)) {
2453 if (!NT_STATUS_IS_OK(result
)) {
2458 /* Display results */
2460 dcerpc_samr_Close(b
, mem_ctx
, &user_pol
, &result
);
2461 dcerpc_samr_Close(b
, mem_ctx
, &domain_pol
, &result
);
2462 dcerpc_samr_Close(b
, mem_ctx
, &connect_pol
, &result
);
2468 /**********************************************************************
2469 * Query user security object
2471 static NTSTATUS
cmd_samr_query_sec_obj(struct rpc_pipe_client
*cli
,
2472 TALLOC_CTX
*mem_ctx
,
2473 int argc
, const char **argv
)
2475 struct policy_handle connect_pol
, domain_pol
, user_pol
, *pol
;
2476 NTSTATUS status
, result
;
2477 uint32_t sec_info
= SECINFO_DACL
;
2478 uint32_t user_rid
= 0;
2479 TALLOC_CTX
*ctx
= NULL
;
2480 struct sec_desc_buf
*sec_desc_buf
=NULL
;
2481 bool domain
= False
;
2482 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
2484 ctx
=talloc_init("cmd_samr_query_sec_obj");
2486 if ((argc
< 1) || (argc
> 3)) {
2487 printf("Usage: %s [rid|-d] [sec_info]\n", argv
[0]);
2488 printf("\tSpecify rid for security on user, -d for security on domain\n");
2489 talloc_destroy(ctx
);
2490 return NT_STATUS_OK
;
2494 if (strcmp(argv
[1], "-d") == 0)
2497 sscanf(argv
[1], "%i", &user_rid
);
2501 sec_info
= atoi(argv
[2]);
2504 status
= rpccli_try_samr_connects(cli
, mem_ctx
,
2505 MAXIMUM_ALLOWED_ACCESS
,
2507 if (!NT_STATUS_IS_OK(status
)) {
2511 if (domain
|| user_rid
) {
2512 status
= dcerpc_samr_OpenDomain(b
, mem_ctx
,
2514 MAXIMUM_ALLOWED_ACCESS
,
2518 if (!NT_STATUS_IS_OK(status
)) {
2521 if (!NT_STATUS_IS_OK(result
)) {
2528 status
= dcerpc_samr_OpenUser(b
, mem_ctx
,
2530 MAXIMUM_ALLOWED_ACCESS
,
2534 if (!NT_STATUS_IS_OK(status
)) {
2537 if (!NT_STATUS_IS_OK(result
)) {
2543 /* Pick which query pol to use */
2553 /* Query SAM security object */
2555 status
= dcerpc_samr_QuerySecurity(b
, mem_ctx
,
2560 if (!NT_STATUS_IS_OK(status
)) {
2563 if (!NT_STATUS_IS_OK(result
)) {
2568 display_sec_desc(sec_desc_buf
->sd
);
2570 dcerpc_samr_Close(b
, mem_ctx
, &user_pol
, &result
);
2571 dcerpc_samr_Close(b
, mem_ctx
, &domain_pol
, &result
);
2572 dcerpc_samr_Close(b
, mem_ctx
, &connect_pol
, &result
);
2574 talloc_destroy(ctx
);
2578 static NTSTATUS
cmd_samr_get_usrdom_pwinfo(struct rpc_pipe_client
*cli
,
2579 TALLOC_CTX
*mem_ctx
,
2580 int argc
, const char **argv
)
2582 NTSTATUS status
, result
;
2583 struct policy_handle connect_pol
, domain_pol
, user_pol
;
2584 struct samr_PwInfo info
;
2586 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
2589 printf("Usage: %s rid\n", argv
[0]);
2590 return NT_STATUS_OK
;
2593 sscanf(argv
[1], "%i", &rid
);
2595 status
= rpccli_try_samr_connects(cli
, mem_ctx
,
2596 MAXIMUM_ALLOWED_ACCESS
,
2598 if (!NT_STATUS_IS_OK(status
)) {
2602 status
= dcerpc_samr_OpenDomain(b
, mem_ctx
,
2604 MAXIMUM_ALLOWED_ACCESS
,
2608 if (!NT_STATUS_IS_OK(status
)) {
2611 if (!NT_STATUS_IS_OK(result
)) {
2616 status
= dcerpc_samr_OpenUser(b
, mem_ctx
,
2618 MAXIMUM_ALLOWED_ACCESS
,
2622 if (!NT_STATUS_IS_OK(status
)) {
2625 if (!NT_STATUS_IS_OK(result
)) {
2630 status
= dcerpc_samr_GetUserPwInfo(b
, mem_ctx
,
2634 if (!NT_STATUS_IS_OK(status
)) {
2638 if (NT_STATUS_IS_OK(result
)) {
2639 printf("min_password_length: %d\n", info
.min_password_length
);
2641 NDR_PRINT_STRUCT_STRING(mem_ctx
,
2642 samr_PasswordProperties
, &info
.password_properties
));
2646 dcerpc_samr_Close(b
, mem_ctx
, &user_pol
, &result
);
2647 dcerpc_samr_Close(b
, mem_ctx
, &domain_pol
, &result
);
2648 dcerpc_samr_Close(b
, mem_ctx
, &connect_pol
, &result
);
2653 static NTSTATUS
cmd_samr_get_dom_pwinfo(struct rpc_pipe_client
*cli
,
2654 TALLOC_CTX
*mem_ctx
,
2655 int argc
, const char **argv
)
2657 NTSTATUS status
, result
;
2658 struct lsa_String domain_name
;
2659 struct samr_PwInfo info
;
2660 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
2662 if (argc
< 1 || argc
> 3) {
2663 printf("Usage: %s <domain>\n", argv
[0]);
2664 return NT_STATUS_OK
;
2667 init_lsa_String(&domain_name
, argv
[1]);
2669 status
= dcerpc_samr_GetDomPwInfo(b
, mem_ctx
,
2673 if (!NT_STATUS_IS_OK(status
)) {
2676 if (NT_STATUS_IS_OK(result
)) {
2677 printf("min_password_length: %d\n", info
.min_password_length
);
2678 display_password_properties(info
.password_properties
);
2684 /* Look up domain name */
2686 static NTSTATUS
cmd_samr_lookup_domain(struct rpc_pipe_client
*cli
,
2687 TALLOC_CTX
*mem_ctx
,
2688 int argc
, const char **argv
)
2690 struct policy_handle connect_pol
, domain_pol
;
2691 NTSTATUS status
, result
;
2692 uint32_t access_mask
= MAXIMUM_ALLOWED_ACCESS
;
2694 struct lsa_String domain_name
;
2695 struct dom_sid
*sid
= NULL
;
2696 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
2699 printf("Usage: %s domain_name\n", argv
[0]);
2700 return NT_STATUS_OK
;
2703 init_lsa_String(&domain_name
, argv
[1]);
2705 status
= rpccli_try_samr_connects(cli
, mem_ctx
,
2708 if (!NT_STATUS_IS_OK(status
)) {
2712 status
= dcerpc_samr_OpenDomain(b
, mem_ctx
,
2718 if (!NT_STATUS_IS_OK(status
)) {
2721 if (!NT_STATUS_IS_OK(result
)) {
2726 status
= dcerpc_samr_LookupDomain(b
, mem_ctx
,
2731 if (!NT_STATUS_IS_OK(status
)) {
2734 if (!NT_STATUS_IS_OK(result
)) {
2739 if (NT_STATUS_IS_OK(result
)) {
2740 sid_to_fstring(sid_string
, sid
);
2741 printf("SAMR_LOOKUP_DOMAIN: Domain Name: %s Domain SID: %s\n",
2742 argv
[1], sid_string
);
2745 dcerpc_samr_Close(b
, mem_ctx
, &domain_pol
, &result
);
2746 dcerpc_samr_Close(b
, mem_ctx
, &connect_pol
, &result
);
2751 /* Change user password */
2753 static NTSTATUS
cmd_samr_chgpasswd(struct rpc_pipe_client
*cli
,
2754 TALLOC_CTX
*mem_ctx
,
2755 int argc
, const char **argv
)
2757 struct policy_handle connect_pol
;
2758 struct policy_handle domain_pol
= { 0, };
2759 struct policy_handle user_pol
= { 0, };
2760 NTSTATUS status
, result
;
2761 const char *user
, *oldpass
, *newpass
;
2762 uint32_t access_mask
= MAXIMUM_ALLOWED_ACCESS
;
2763 struct samr_Ids rids
, types
;
2764 struct lsa_String lsa_acct_name
;
2765 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
2768 printf("Usage: %s username oldpass newpass\n", argv
[0]);
2769 return NT_STATUS_INVALID_PARAMETER
;
2776 /* Get sam policy handle */
2778 status
= rpccli_try_samr_connects(cli
, mem_ctx
,
2779 MAXIMUM_ALLOWED_ACCESS
,
2781 if (!NT_STATUS_IS_OK(status
)) {
2785 /* Get domain policy handle */
2787 status
= dcerpc_samr_OpenDomain(b
, mem_ctx
,
2793 if (!NT_STATUS_IS_OK(status
)) {
2796 if (!NT_STATUS_IS_OK(result
)) {
2801 init_lsa_String(&lsa_acct_name
, user
);
2803 status
= dcerpc_samr_LookupNames(b
, mem_ctx
,
2810 if (!NT_STATUS_IS_OK(status
)) {
2813 if (!NT_STATUS_IS_OK(result
)) {
2817 if (rids
.count
!= 1) {
2818 status
= NT_STATUS_INVALID_NETWORK_RESPONSE
;
2821 if (types
.count
!= 1) {
2822 status
= NT_STATUS_INVALID_NETWORK_RESPONSE
;
2826 status
= dcerpc_samr_OpenUser(b
, mem_ctx
,
2832 if (!NT_STATUS_IS_OK(status
)) {
2835 if (!NT_STATUS_IS_OK(result
)) {
2840 /* Change user password */
2841 status
= rpccli_samr_chgpasswd_user(cli
, mem_ctx
,
2845 if (!NT_STATUS_IS_OK(status
)) {
2850 if (is_valid_policy_hnd(&user_pol
)) {
2851 dcerpc_samr_Close(b
, mem_ctx
, &user_pol
, &result
);
2853 if (is_valid_policy_hnd(&domain_pol
)) {
2854 dcerpc_samr_Close(b
, mem_ctx
, &domain_pol
, &result
);
2856 if (is_valid_policy_hnd(&connect_pol
)) {
2857 dcerpc_samr_Close(b
, mem_ctx
, &connect_pol
, &result
);
2864 /* Change user password */
2866 static NTSTATUS
cmd_samr_chgpasswd2(struct rpc_pipe_client
*cli
,
2867 TALLOC_CTX
*mem_ctx
,
2868 int argc
, const char **argv
)
2870 struct policy_handle connect_pol
, domain_pol
;
2871 NTSTATUS status
, result
;
2872 const char *user
, *oldpass
, *newpass
;
2873 uint32_t access_mask
= MAXIMUM_ALLOWED_ACCESS
;
2874 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
2877 printf("Usage: %s username oldpass newpass\n", argv
[0]);
2878 return NT_STATUS_INVALID_PARAMETER
;
2885 /* Get sam policy handle */
2887 status
= rpccli_try_samr_connects(cli
, mem_ctx
,
2888 MAXIMUM_ALLOWED_ACCESS
,
2890 if (!NT_STATUS_IS_OK(status
)) {
2894 /* Get domain policy handle */
2896 status
= dcerpc_samr_OpenDomain(b
, mem_ctx
,
2902 if (!NT_STATUS_IS_OK(status
)) {
2905 if (!NT_STATUS_IS_OK(result
)) {
2910 /* Change user password */
2911 status
= rpccli_samr_chgpasswd_user2(cli
, mem_ctx
, user
, newpass
, oldpass
);
2913 if (!NT_STATUS_IS_OK(status
)) {
2917 status
= dcerpc_samr_Close(b
, mem_ctx
, &domain_pol
, &result
);
2918 if (!NT_STATUS_IS_OK(status
)) goto done
;
2920 status
= dcerpc_samr_Close(b
, mem_ctx
, &connect_pol
, &result
);
2921 if (!NT_STATUS_IS_OK(status
)) goto done
;
2928 /* Change user password */
2930 static NTSTATUS
cmd_samr_chgpasswd3(struct rpc_pipe_client
*cli
,
2931 TALLOC_CTX
*mem_ctx
,
2932 int argc
, const char **argv
)
2934 struct policy_handle connect_pol
, domain_pol
;
2935 NTSTATUS status
, result
;
2936 const char *user
, *oldpass
, *newpass
;
2937 uint32_t access_mask
= MAXIMUM_ALLOWED_ACCESS
;
2938 struct samr_DomInfo1
*info
= NULL
;
2939 struct userPwdChangeFailureInformation
*reject
= NULL
;
2940 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
2943 printf("Usage: %s username oldpass newpass\n", argv
[0]);
2944 return NT_STATUS_INVALID_PARAMETER
;
2951 /* Get sam policy handle */
2953 status
= rpccli_try_samr_connects(cli
, mem_ctx
,
2954 MAXIMUM_ALLOWED_ACCESS
,
2956 if (!NT_STATUS_IS_OK(status
)) {
2960 /* Get domain policy handle */
2962 status
= dcerpc_samr_OpenDomain(b
, mem_ctx
,
2968 if (!NT_STATUS_IS_OK(status
)) {
2971 if (!NT_STATUS_IS_OK(result
)) {
2976 /* Change user password */
2977 status
= rpccli_samr_chgpasswd_user3(cli
, mem_ctx
,
2983 if (!NT_STATUS_IS_OK(status
)) {
2987 if (NT_STATUS_EQUAL(result
, NT_STATUS_PASSWORD_RESTRICTION
)) {
2989 display_sam_dom_info_1(info
);
2991 switch (reject
->extendedFailureReason
) {
2992 case SAM_PWD_CHANGE_PASSWORD_TOO_SHORT
:
2993 d_printf("SAM_PWD_CHANGE_PASSWORD_TOO_SHORT\n");
2995 case SAM_PWD_CHANGE_PWD_IN_HISTORY
:
2996 d_printf("SAM_PWD_CHANGE_PWD_IN_HISTORY\n");
2998 case SAM_PWD_CHANGE_NOT_COMPLEX
:
2999 d_printf("SAM_PWD_CHANGE_NOT_COMPLEX\n");
3002 d_printf("unknown reject reason: %d\n",
3003 reject
->extendedFailureReason
);
3008 if (!NT_STATUS_IS_OK(result
)) {
3013 status
= dcerpc_samr_Close(b
, mem_ctx
, &domain_pol
, &result
);
3014 if (!NT_STATUS_IS_OK(status
)) goto done
;
3016 status
= dcerpc_samr_Close(b
, mem_ctx
, &connect_pol
, &result
);
3017 if (!NT_STATUS_IS_OK(status
)) goto done
;
3023 static NTSTATUS
cmd_samr_setuserinfo_int(struct rpc_pipe_client
*cli
,
3024 TALLOC_CTX
*mem_ctx
,
3025 int argc
, const char **argv
,
3028 struct policy_handle connect_pol
, domain_pol
, user_pol
;
3029 NTSTATUS status
, result
;
3030 const char *user
, *param
;
3031 uint32_t access_mask
= MAXIMUM_ALLOWED_ACCESS
;
3034 union samr_UserInfo info
;
3035 struct samr_CryptPassword pwd_buf
;
3036 struct samr_CryptPasswordEx pwd_buf_ex
;
3037 uint8_t nt_hash
[16];
3038 uint8_t lm_hash
[16];
3039 DATA_BLOB session_key
;
3040 uint8_t password_expired
= 0;
3041 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
3044 printf("Usage: %s username level password [password_expired]\n",
3046 return NT_STATUS_INVALID_PARAMETER
;
3050 level
= atoi(argv
[2]);
3054 password_expired
= atoi(argv
[4]);
3057 status
= cli_get_session_key(mem_ctx
, cli
, &session_key
);
3058 if (!NT_STATUS_IS_OK(status
)) {
3062 init_samr_CryptPassword(param
, &session_key
, &pwd_buf
);
3063 init_samr_CryptPasswordEx(param
, &session_key
, &pwd_buf_ex
);
3064 nt_lm_owf_gen(param
, nt_hash
, lm_hash
);
3070 in
= data_blob_const(nt_hash
, 16);
3071 out
= data_blob_talloc_zero(mem_ctx
, 16);
3072 sess_crypt_blob(&out
, &in
, &session_key
, true);
3073 memcpy(nt_hash
, out
.data
, out
.length
);
3077 in
= data_blob_const(lm_hash
, 16);
3078 out
= data_blob_talloc_zero(mem_ctx
, 16);
3079 sess_crypt_blob(&out
, &in
, &session_key
, true);
3080 memcpy(lm_hash
, out
.data
, out
.length
);
3083 memcpy(info
.info18
.nt_pwd
.hash
, nt_hash
, 16);
3084 memcpy(info
.info18
.lm_pwd
.hash
, lm_hash
, 16);
3085 info
.info18
.nt_pwd_active
= true;
3086 info
.info18
.lm_pwd_active
= true;
3087 info
.info18
.password_expired
= password_expired
;
3091 ZERO_STRUCT(info
.info21
);
3093 info
.info21
.fields_present
= SAMR_FIELD_NT_PASSWORD_PRESENT
|
3094 SAMR_FIELD_LM_PASSWORD_PRESENT
;
3096 info
.info21
.fields_present
|= SAMR_FIELD_EXPIRED_FLAG
;
3097 info
.info21
.password_expired
= password_expired
;
3100 info
.info21
.lm_password_set
= true;
3101 info
.info21
.lm_owf_password
.length
= 16;
3102 info
.info21
.lm_owf_password
.size
= 16;
3104 info
.info21
.nt_password_set
= true;
3105 info
.info21
.nt_owf_password
.length
= 16;
3106 info
.info21
.nt_owf_password
.size
= 16;
3110 in
= data_blob_const(nt_hash
, 16);
3111 out
= data_blob_talloc_zero(mem_ctx
, 16);
3112 sess_crypt_blob(&out
, &in
, &session_key
, true);
3113 info
.info21
.nt_owf_password
.array
=
3114 (uint16_t *)talloc_memdup(mem_ctx
, out
.data
, 16);
3118 in
= data_blob_const(lm_hash
, 16);
3119 out
= data_blob_talloc_zero(mem_ctx
, 16);
3120 sess_crypt_blob(&out
, &in
, &session_key
, true);
3121 info
.info21
.lm_owf_password
.array
=
3122 (uint16_t *)talloc_memdup(mem_ctx
, out
.data
, 16);
3127 ZERO_STRUCT(info
.info23
);
3129 info
.info23
.info
.fields_present
= SAMR_FIELD_NT_PASSWORD_PRESENT
|
3130 SAMR_FIELD_LM_PASSWORD_PRESENT
;
3132 info
.info23
.info
.fields_present
|= SAMR_FIELD_EXPIRED_FLAG
;
3133 info
.info23
.info
.password_expired
= password_expired
;
3136 info
.info23
.password
= pwd_buf
;
3140 info
.info24
.password
= pwd_buf
;
3141 info
.info24
.password_expired
= password_expired
;
3145 ZERO_STRUCT(info
.info25
);
3147 info
.info25
.info
.fields_present
= SAMR_FIELD_NT_PASSWORD_PRESENT
|
3148 SAMR_FIELD_LM_PASSWORD_PRESENT
;
3150 info
.info25
.info
.fields_present
|= SAMR_FIELD_EXPIRED_FLAG
;
3151 info
.info25
.info
.password_expired
= password_expired
;
3154 info
.info25
.password
= pwd_buf_ex
;
3158 info
.info26
.password
= pwd_buf_ex
;
3159 info
.info26
.password_expired
= password_expired
;
3163 return NT_STATUS_INVALID_INFO_CLASS
;
3166 /* Get sam policy handle */
3168 status
= rpccli_try_samr_connects(cli
, mem_ctx
,
3169 MAXIMUM_ALLOWED_ACCESS
,
3171 if (!NT_STATUS_IS_OK(status
)) {
3175 /* Get domain policy handle */
3177 status
= dcerpc_samr_OpenDomain(b
, mem_ctx
,
3184 if (!NT_STATUS_IS_OK(status
))
3186 if (!NT_STATUS_IS_OK(result
)) {
3191 user_rid
= strtol(user
, NULL
, 0);
3193 status
= dcerpc_samr_OpenUser(b
, mem_ctx
,
3199 if (!NT_STATUS_IS_OK(status
)) {
3206 if (NT_STATUS_EQUAL(status
, NT_STATUS_NO_SUCH_USER
) ||
3209 /* Probably this was a user name, try lookupnames */
3210 struct samr_Ids rids
, types
;
3211 struct lsa_String lsa_acct_name
;
3213 init_lsa_String(&lsa_acct_name
, user
);
3215 status
= dcerpc_samr_LookupNames(b
, mem_ctx
,
3222 if (!NT_STATUS_IS_OK(status
)) {
3225 if (!NT_STATUS_IS_OK(result
)) {
3228 if (rids
.count
!= 1) {
3229 return NT_STATUS_INVALID_NETWORK_RESPONSE
;
3231 if (types
.count
!= 1) {
3232 return NT_STATUS_INVALID_NETWORK_RESPONSE
;
3235 status
= dcerpc_samr_OpenUser(b
, mem_ctx
,
3241 if (!NT_STATUS_IS_OK(status
)) {
3244 if (!NT_STATUS_IS_OK(result
)) {
3250 case NDR_SAMR_SETUSERINFO
:
3251 status
= dcerpc_samr_SetUserInfo(b
, mem_ctx
,
3257 case NDR_SAMR_SETUSERINFO2
:
3258 status
= dcerpc_samr_SetUserInfo2(b
, mem_ctx
,
3265 return NT_STATUS_INVALID_PARAMETER
;
3267 if (!NT_STATUS_IS_OK(status
)) {
3268 DEBUG(0,("status: %s\n", nt_errstr(status
)));
3271 if (!NT_STATUS_IS_OK(result
)) {
3273 DEBUG(0,("result: %s\n", nt_errstr(status
)));
3280 static NTSTATUS
cmd_samr_setuserinfo(struct rpc_pipe_client
*cli
,
3281 TALLOC_CTX
*mem_ctx
,
3282 int argc
, const char **argv
)
3284 return cmd_samr_setuserinfo_int(cli
, mem_ctx
, argc
, argv
,
3285 NDR_SAMR_SETUSERINFO
);
3288 static NTSTATUS
cmd_samr_setuserinfo2(struct rpc_pipe_client
*cli
,
3289 TALLOC_CTX
*mem_ctx
,
3290 int argc
, const char **argv
)
3292 return cmd_samr_setuserinfo_int(cli
, mem_ctx
, argc
, argv
,
3293 NDR_SAMR_SETUSERINFO2
);
3296 static NTSTATUS
cmd_samr_get_dispinfo_idx(struct rpc_pipe_client
*cli
,
3297 TALLOC_CTX
*mem_ctx
,
3298 int argc
, const char **argv
)
3300 NTSTATUS status
, result
;
3301 struct policy_handle connect_handle
;
3302 struct policy_handle domain_handle
= { 0, };
3304 struct lsa_String name
;
3306 struct dcerpc_binding_handle
*b
= cli
->binding_handle
;
3308 if (argc
< 2 || argc
> 3) {
3309 printf("Usage: %s name level\n", argv
[0]);
3310 return NT_STATUS_INVALID_PARAMETER
;
3313 init_lsa_String(&name
, argv
[1]);
3316 level
= atoi(argv
[2]);
3319 status
= rpccli_try_samr_connects(cli
, mem_ctx
,
3320 SEC_FLAG_MAXIMUM_ALLOWED
,
3322 if (!NT_STATUS_IS_OK(status
)) {
3326 status
= dcerpc_samr_OpenDomain(b
, mem_ctx
,
3328 SEC_FLAG_MAXIMUM_ALLOWED
,
3332 if (!NT_STATUS_IS_OK(status
)) {
3335 if (!NT_STATUS_IS_OK(result
)) {
3340 status
= dcerpc_samr_GetDisplayEnumerationIndex(b
, mem_ctx
,
3346 if (!NT_STATUS_IS_OK(status
)) {
3352 if (NT_STATUS_IS_OK(status
) ||
3353 NT_STATUS_EQUAL(status
, NT_STATUS_NO_MORE_ENTRIES
)) {
3354 printf("idx: %d (0x%08x)\n", idx
, idx
);
3358 if (is_valid_policy_hnd(&domain_handle
)) {
3359 dcerpc_samr_Close(b
, mem_ctx
, &domain_handle
, &result
);
3361 if (is_valid_policy_hnd(&connect_handle
)) {
3362 dcerpc_samr_Close(b
, mem_ctx
, &connect_handle
, &result
);
3368 /* List of commands exported by this module */
3370 struct cmd_set samr_commands
[] = {
3374 { "queryuser", RPC_RTYPE_NTSTATUS
, cmd_samr_query_user
, NULL
, &ndr_table_samr
, NULL
, "Query user info", "" },
3375 { "querygroup", RPC_RTYPE_NTSTATUS
, cmd_samr_query_group
, NULL
, &ndr_table_samr
, NULL
, "Query group info", "" },
3376 { "queryusergroups", RPC_RTYPE_NTSTATUS
, cmd_samr_query_usergroups
, NULL
, &ndr_table_samr
, NULL
, "Query user groups", "" },
3377 { "queryuseraliases", RPC_RTYPE_NTSTATUS
, cmd_samr_query_useraliases
, NULL
, &ndr_table_samr
, NULL
, "Query user aliases", "" },
3378 { "querygroupmem", RPC_RTYPE_NTSTATUS
, cmd_samr_query_groupmem
, NULL
, &ndr_table_samr
, NULL
, "Query group membership", "" },
3379 { "queryaliasmem", RPC_RTYPE_NTSTATUS
, cmd_samr_query_aliasmem
, NULL
, &ndr_table_samr
, NULL
, "Query alias membership", "" },
3380 { "queryaliasinfo", RPC_RTYPE_NTSTATUS
, cmd_samr_query_aliasinfo
, NULL
, &ndr_table_samr
, NULL
, "Query alias info", "" },
3381 { "deletealias", RPC_RTYPE_NTSTATUS
, cmd_samr_delete_alias
, NULL
, &ndr_table_samr
, NULL
, "Delete an alias", "" },
3382 { "querydispinfo", RPC_RTYPE_NTSTATUS
, cmd_samr_query_dispinfo
, NULL
, &ndr_table_samr
, NULL
, "Query display info", "" },
3383 { "querydispinfo2", RPC_RTYPE_NTSTATUS
, cmd_samr_query_dispinfo2
, NULL
, &ndr_table_samr
, NULL
, "Query display info", "" },
3384 { "querydispinfo3", RPC_RTYPE_NTSTATUS
, cmd_samr_query_dispinfo3
, NULL
, &ndr_table_samr
, NULL
, "Query display info", "" },
3385 { "querydominfo", RPC_RTYPE_NTSTATUS
, cmd_samr_query_dominfo
, NULL
, &ndr_table_samr
, NULL
, "Query domain info", "" },
3386 { "enumdomusers", RPC_RTYPE_NTSTATUS
, cmd_samr_enum_dom_users
, NULL
, &ndr_table_samr
, NULL
, "Enumerate domain users", "" },
3387 { "enumdomgroups", RPC_RTYPE_NTSTATUS
, cmd_samr_enum_dom_groups
, NULL
, &ndr_table_samr
, NULL
, "Enumerate domain groups", "" },
3388 { "enumalsgroups", RPC_RTYPE_NTSTATUS
, cmd_samr_enum_als_groups
, NULL
, &ndr_table_samr
, NULL
, "Enumerate alias groups", "" },
3389 { "enumdomains", RPC_RTYPE_NTSTATUS
, cmd_samr_enum_domains
, NULL
, &ndr_table_samr
, NULL
, "Enumerate domains", "" },
3391 { "createdomuser", RPC_RTYPE_NTSTATUS
, cmd_samr_create_dom_user
, NULL
, &ndr_table_samr
, NULL
, "Create domain user", "" },
3392 { "createdomgroup", RPC_RTYPE_NTSTATUS
, cmd_samr_create_dom_group
, NULL
, &ndr_table_samr
, NULL
, "Create domain group", "" },
3393 { "createdomalias", RPC_RTYPE_NTSTATUS
, cmd_samr_create_dom_alias
, NULL
, &ndr_table_samr
, NULL
, "Create domain alias", "" },
3394 { "samlookupnames", RPC_RTYPE_NTSTATUS
, cmd_samr_lookup_names
, NULL
, &ndr_table_samr
, NULL
, "Look up names", "" },
3395 { "samlookuprids", RPC_RTYPE_NTSTATUS
, cmd_samr_lookup_rids
, NULL
, &ndr_table_samr
, NULL
, "Look up names", "" },
3396 { "deletedomgroup", RPC_RTYPE_NTSTATUS
, cmd_samr_delete_dom_group
, NULL
, &ndr_table_samr
, NULL
, "Delete domain group", "" },
3397 { "deletedomuser", RPC_RTYPE_NTSTATUS
, cmd_samr_delete_dom_user
, NULL
, &ndr_table_samr
, NULL
, "Delete domain user", "" },
3398 { "samquerysecobj", RPC_RTYPE_NTSTATUS
, cmd_samr_query_sec_obj
, NULL
, &ndr_table_samr
, NULL
, "Query SAMR security object", "" },
3399 { "getdompwinfo", RPC_RTYPE_NTSTATUS
, cmd_samr_get_dom_pwinfo
, NULL
, &ndr_table_samr
, NULL
, "Retrieve domain password info", "" },
3400 { "getusrdompwinfo", RPC_RTYPE_NTSTATUS
, cmd_samr_get_usrdom_pwinfo
, NULL
, &ndr_table_samr
, NULL
, "Retrieve user domain password info", "" },
3402 { "lookupdomain", RPC_RTYPE_NTSTATUS
, cmd_samr_lookup_domain
, NULL
, &ndr_table_samr
, NULL
, "Lookup Domain Name", "" },
3403 { "chgpasswd", RPC_RTYPE_NTSTATUS
, cmd_samr_chgpasswd
, NULL
, &ndr_table_samr
, NULL
, "Change user password", "" },
3404 { "chgpasswd2", RPC_RTYPE_NTSTATUS
, cmd_samr_chgpasswd2
, NULL
, &ndr_table_samr
, NULL
, "Change user password", "" },
3405 { "chgpasswd3", RPC_RTYPE_NTSTATUS
, cmd_samr_chgpasswd3
, NULL
, &ndr_table_samr
, NULL
, "Change user password", "" },
3406 { "getdispinfoidx", RPC_RTYPE_NTSTATUS
, cmd_samr_get_dispinfo_idx
, NULL
, &ndr_table_samr
, NULL
, "Get Display Information Index", "" },
3407 { "setuserinfo", RPC_RTYPE_NTSTATUS
, cmd_samr_setuserinfo
, NULL
, &ndr_table_samr
, NULL
, "Set user info", "" },
3408 { "setuserinfo2", RPC_RTYPE_NTSTATUS
, cmd_samr_setuserinfo2
, NULL
, &ndr_table_samr
, NULL
, "Set user info2", "" },