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
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
25 #include "rpcclient.h"
27 extern DOM_SID domain_sid;
29 /****************************************************************************
30 display sam_user_info_7 structure
31 ****************************************************************************/
32 static void display_sam_user_info_7(SAM_USER_INFO_7 *usr)
36 unistr2_to_ascii(temp, &usr->uni_name, sizeof(temp));
37 printf("\tUser Name :\t%s\n", temp);
40 /****************************************************************************
41 display sam_user_info_9 structure
42 ****************************************************************************/
43 static void display_sam_user_info_9(SAM_USER_INFO_9 *usr)
45 printf("\tPrimary group RID :\tox%x\n", usr->rid_group);
48 /****************************************************************************
49 display sam_user_info_16 structure
50 ****************************************************************************/
51 static void display_sam_user_info_16(SAM_USER_INFO_16 *usr)
53 printf("\tAcct Flags :\tox%x\n", usr->acb_info);
56 /****************************************************************************
57 display sam_user_info_21 structure
58 ****************************************************************************/
59 static void display_sam_user_info_21(SAM_USER_INFO_21 *usr)
63 unistr2_to_ascii(temp, &usr->uni_user_name, sizeof(temp));
64 printf("\tUser Name :\t%s\n", temp);
66 unistr2_to_ascii(temp, &usr->uni_full_name, sizeof(temp));
67 printf("\tFull Name :\t%s\n", temp);
69 unistr2_to_ascii(temp, &usr->uni_home_dir, sizeof(temp));
70 printf("\tHome Drive :\t%s\n", temp);
72 unistr2_to_ascii(temp, &usr->uni_dir_drive, sizeof(temp));
73 printf("\tDir Drive :\t%s\n", temp);
75 unistr2_to_ascii(temp, &usr->uni_profile_path, sizeof(temp));
76 printf("\tProfile Path:\t%s\n", temp);
78 unistr2_to_ascii(temp, &usr->uni_logon_script, sizeof(temp));
79 printf("\tLogon Script:\t%s\n", temp);
81 unistr2_to_ascii(temp, &usr->uni_acct_desc, sizeof(temp));
82 printf("\tDescription :\t%s\n", temp);
84 unistr2_to_ascii(temp, &usr->uni_workstations, sizeof(temp));
85 printf("\tWorkstations:\t%s\n", temp);
87 unistr2_to_ascii(temp, &usr->uni_comment, sizeof(temp));
88 printf("\tUnknown Str :\t%s\n", temp);
90 unistr2_to_ascii(temp, &usr->uni_munged_dial, sizeof(temp));
91 printf("\tRemote Dial :\t%s\n", temp);
93 printf("\tLogon Time :\t%s\n",
94 http_timestring(nt_time_to_unix(usr->logon_time)));
95 printf("\tLogoff Time :\t%s\n",
96 http_timestring(nt_time_to_unix(usr->logoff_time)));
97 printf("\tKickoff Time :\t%s\n",
98 http_timestring(nt_time_to_unix(usr->kickoff_time)));
99 printf("\tPassword last set Time :\t%s\n",
100 http_timestring(nt_time_to_unix(usr->pass_last_set_time)));
101 printf("\tPassword can change Time :\t%s\n",
102 http_timestring(nt_time_to_unix(usr->pass_can_change_time)));
103 printf("\tPassword must change Time:\t%s\n",
104 http_timestring(nt_time_to_unix(usr->pass_must_change_time)));
106 printf("\tunknown_2[0..31]...\n"); /* user passwords? */
108 printf("\tuser_rid :\t0x%x\n" , usr->user_rid ); /* User ID */
109 printf("\tgroup_rid:\t0x%x\n" , usr->group_rid); /* Group ID */
110 printf("\tacb_info :\t0x%08x\n", usr->acb_info ); /* Account Control Info */
112 printf("\tfields_present:\t0x%08x\n", usr->fields_present); /* 0x00ff ffff */
113 printf("\tlogon_divs:\t%d\n", usr->logon_divs); /* 0x0000 00a8 which is 168 which is num hrs in a week */
114 printf("\tbad_password_count:\t0x%08x\n", usr->bad_password_count);
115 printf("\tlogon_count:\t0x%08x\n", usr->logon_count);
117 printf("\tpadding1[0..7]...\n");
119 if (usr->ptr_logon_hrs) {
120 printf("\tlogon_hrs[0..%d]...\n", usr->logon_hrs.len);
125 static void display_password_properties(uint32 password_properties)
127 printf("password_properties: 0x%08x\n", password_properties);
129 if (password_properties & DOMAIN_PASSWORD_COMPLEX)
130 printf("\tDOMAIN_PASSWORD_COMPLEX\n");
132 if (password_properties & DOMAIN_PASSWORD_NO_ANON_CHANGE)
133 printf("\tDOMAIN_PASSWORD_NO_ANON_CHANGE\n");
135 if (password_properties & DOMAIN_PASSWORD_NO_CLEAR_CHANGE)
136 printf("\tDOMAIN_PASSWORD_NO_CLEAR_CHANGE\n");
138 if (password_properties & DOMAIN_LOCKOUT_ADMINS)
139 printf("\tDOMAIN_LOCKOUT_ADMINS\n");
141 if (password_properties & DOMAIN_PASSWORD_STORE_CLEARTEXT)
142 printf("\tDOMAIN_PASSWORD_STORE_CLEARTEXT\n");
144 if (password_properties & DOMAIN_REFUSE_PASSWORD_CHANGE)
145 printf("\tDOMAIN_REFUSE_PASSWORD_CHANGE\n");
148 static void display_sam_unk_info_1(SAM_UNK_INFO_1 *info1)
151 printf("Minimum password length:\t\t\t%d\n", info1->min_length_password);
152 printf("Password uniqueness (remember x passwords):\t%d\n", info1->password_history);
153 display_password_properties(info1->password_properties);
154 printf("password expire in:\t\t\t\t%s\n", display_time(info1->expire));
155 printf("Min password age (allow changing in x days):\t%s\n", display_time(info1->min_passwordage));
158 static void display_sam_unk_info_2(SAM_UNK_INFO_2 *info2)
162 unistr2_to_ascii(name, &info2->uni_domain, sizeof(name));
163 printf("Domain:\t\t%s\n", name);
165 unistr2_to_ascii(name, &info2->uni_server, sizeof(name));
166 printf("Server:\t\t%s\n", name);
168 unistr2_to_ascii(name, &info2->uni_comment, sizeof(name));
169 printf("Comment:\t%s\n", name);
171 printf("Total Users:\t%d\n", info2->num_domain_usrs);
172 printf("Total Groups:\t%d\n", info2->num_domain_grps);
173 printf("Total Aliases:\t%d\n", info2->num_local_grps);
175 printf("Sequence No:\t%llu\n", (unsigned long long)info2->seq_num);
177 printf("Force Logoff:\t%d\n", (int)nt_time_to_unix_abs(&info2->logout));
179 printf("Unknown 4:\t0x%x\n", info2->unknown_4);
180 printf("Server Role:\t%s\n", server_role_str(info2->server_role));
181 printf("Unknown 6:\t0x%x\n", info2->unknown_6);
184 static void display_sam_unk_info_3(SAM_UNK_INFO_3 *info3)
186 printf("Force Logoff:\t%d\n", (int)nt_time_to_unix_abs(&info3->logout));
189 static void display_sam_unk_info_4(SAM_UNK_INFO_4 *info4)
193 unistr2_to_ascii(name, &info4->uni_comment, sizeof(name));
194 printf("Comment:\t%s\n", name);
197 static void display_sam_unk_info_5(SAM_UNK_INFO_5 *info5)
201 unistr2_to_ascii(name, &info5->uni_domain, sizeof(name));
202 printf("Domain:\t\t%s\n", name);
205 static void display_sam_unk_info_6(SAM_UNK_INFO_6 *info6)
209 unistr2_to_ascii(name, &info6->uni_server, sizeof(name));
210 printf("Server:\t\t%s\n", name);
213 static void display_sam_unk_info_7(SAM_UNK_INFO_7 *info7)
215 printf("Server Role:\t%s\n", server_role_str(info7->server_role));
218 static void display_sam_unk_info_8(SAM_UNK_INFO_8 *info8)
220 printf("Sequence No:\t%llu\n", (unsigned long long)info8->seq_num);
221 printf("Domain Create Time:\t%s\n",
222 http_timestring(nt_time_to_unix(info8->domain_create_time)));
225 static void display_sam_unk_info_9(SAM_UNK_INFO_9 *info9)
227 printf("unknown:\t%d (0x%08x)\n", info9->unknown, info9->unknown);
230 static void display_sam_unk_info_12(SAM_UNK_INFO_12 *info12)
232 printf("Bad password lockout duration: %s\n", display_time(info12->duration));
233 printf("Reset Lockout after: %s\n", display_time(info12->reset_count));
234 printf("Lockout after bad attempts: %d\n", info12->bad_attempt_lockout);
237 static void display_sam_unk_info_13(SAM_UNK_INFO_13 *info13)
239 printf("Sequence No:\t%llu\n", (unsigned long long)info13->seq_num);
240 printf("Domain Create Time:\t%s\n",
241 http_timestring(nt_time_to_unix(info13->domain_create_time)));
242 printf("Unknown1:\t%d\n", info13->unknown1);
243 printf("Unknown2:\t%d\n", info13->unknown2);
247 static void display_sam_info_1(SAM_ENTRY1 *e1, SAM_STR1 *s1)
251 printf("index: 0x%x ", e1->user_idx);
252 printf("RID: 0x%x ", e1->rid_user);
253 printf("acb: 0x%x ", e1->acb_info);
255 unistr2_to_ascii(tmp, &s1->uni_acct_name, sizeof(tmp));
256 printf("Account: %s\t", tmp);
258 unistr2_to_ascii(tmp, &s1->uni_full_name, sizeof(tmp));
259 printf("Name: %s\t", tmp);
261 unistr2_to_ascii(tmp, &s1->uni_acct_desc, sizeof(tmp));
262 printf("Desc: %s\n", tmp);
265 static void display_sam_info_2(SAM_ENTRY2 *e2, SAM_STR2 *s2)
269 printf("index: 0x%x ", e2->user_idx);
270 printf("RID: 0x%x ", e2->rid_user);
271 printf("acb: 0x%x ", e2->acb_info);
273 unistr2_to_ascii(tmp, &s2->uni_srv_name, sizeof(tmp));
274 printf("Account: %s\t", tmp);
276 unistr2_to_ascii(tmp, &s2->uni_srv_desc, sizeof(tmp));
277 printf("Name: %s\n", tmp);
281 static void display_sam_info_3(SAM_ENTRY3 *e3, SAM_STR3 *s3)
285 printf("index: 0x%x ", e3->grp_idx);
286 printf("RID: 0x%x ", e3->rid_grp);
287 printf("attr: 0x%x ", e3->attr);
289 unistr2_to_ascii(tmp, &s3->uni_grp_name, sizeof(tmp));
290 printf("Account: %s\t", tmp);
292 unistr2_to_ascii(tmp, &s3->uni_grp_desc, sizeof(tmp));
293 printf("Name: %s\n", tmp);
297 static void display_sam_info_4(SAM_ENTRY4 *e4, SAM_STR4 *s4)
301 printf("index: %d ", e4->user_idx);
304 for (i=0; i<s4->acct_name.str_str_len; i++)
305 printf("%c", s4->acct_name.buffer[i]);
310 static void display_sam_info_5(SAM_ENTRY5 *e5, SAM_STR5 *s5)
314 printf("index: 0x%x ", e5->grp_idx);
317 for (i=0; i<s5->grp_name.str_str_len; i++)
318 printf("%c", s5->grp_name.buffer[i]);
323 /****************************************************************************
324 Try samr_connect4 first, then samr_conenct if it fails
325 ****************************************************************************/
326 static NTSTATUS try_samr_connects(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
327 uint32 access_mask, POLICY_HND *connect_pol)
329 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
331 result = rpccli_samr_connect4(cli, mem_ctx, access_mask, connect_pol);
332 if (!NT_STATUS_IS_OK(result)) {
333 result = rpccli_samr_connect(cli, mem_ctx, access_mask,
339 /**********************************************************************
340 * Query user information
342 static NTSTATUS cmd_samr_query_user(struct rpc_pipe_client *cli,
344 int argc, const char **argv)
346 POLICY_HND connect_pol, domain_pol, user_pol;
347 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
348 uint32 info_level = 21;
349 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
350 SAM_USERINFO_CTR *user_ctr;
354 if ((argc < 2) || (argc > 4)) {
355 printf("Usage: %s rid [info level] [access mask] \n", argv[0]);
359 sscanf(argv[1], "%i", &user_rid);
362 sscanf(argv[2], "%i", &info_level);
365 sscanf(argv[3], "%x", &access_mask);
368 slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
371 result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
374 if (!NT_STATUS_IS_OK(result))
377 result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
378 MAXIMUM_ALLOWED_ACCESS,
379 &domain_sid, &domain_pol);
381 if (!NT_STATUS_IS_OK(result))
384 result = rpccli_samr_open_user(cli, mem_ctx, &domain_pol,
386 user_rid, &user_pol);
388 if (NT_STATUS_EQUAL(result, NT_STATUS_NO_SUCH_USER) &&
391 /* Probably this was a user name, try lookupnames */
393 uint32 *rids, *types;
395 result = rpccli_samr_lookup_names(cli, mem_ctx, &domain_pol,
400 if (NT_STATUS_IS_OK(result)) {
401 result = rpccli_samr_open_user(cli, mem_ctx,
409 if (!NT_STATUS_IS_OK(result))
412 ZERO_STRUCT(user_ctr);
414 result = rpccli_samr_query_userinfo(cli, mem_ctx, &user_pol,
415 info_level, &user_ctr);
417 if (!NT_STATUS_IS_OK(result))
420 switch (user_ctr->switch_value) {
422 display_sam_user_info_7(user_ctr->info.id7);
425 display_sam_user_info_9(user_ctr->info.id9);
428 display_sam_user_info_16(user_ctr->info.id16);
431 display_sam_user_info_21(user_ctr->info.id21);
434 printf("Unsupported infolevel: %d\n", info_level);
438 rpccli_samr_close(cli, mem_ctx, &user_pol);
439 rpccli_samr_close(cli, mem_ctx, &domain_pol);
440 rpccli_samr_close(cli, mem_ctx, &connect_pol);
446 /****************************************************************************
448 ****************************************************************************/
449 static void display_group_info1(GROUP_INFO1 *info1)
453 unistr2_to_ascii(temp, &info1->uni_acct_name, sizeof(temp));
454 printf("\tGroup Name:\t%s\n", temp);
455 unistr2_to_ascii(temp, &info1->uni_acct_desc, sizeof(temp));
456 printf("\tDescription:\t%s\n", temp);
457 printf("\tGroup Attribute:%d\n", info1->group_attr);
458 printf("\tNum Members:%d\n", info1->num_members);
461 /****************************************************************************
463 ****************************************************************************/
464 static void display_group_info2(GROUP_INFO2 *info2)
468 unistr2_to_ascii(name, &info2->uni_acct_name, sizeof(name));
469 printf("\tGroup Description:%s\n", name);
473 /****************************************************************************
475 ****************************************************************************/
476 static void display_group_info3(GROUP_INFO3 *info3)
478 printf("\tGroup Attribute:%d\n", info3->group_attr);
482 /****************************************************************************
484 ****************************************************************************/
485 static void display_group_info4(GROUP_INFO4 *info4)
489 unistr2_to_ascii(desc, &info4->uni_acct_desc, sizeof(desc));
490 printf("\tGroup Description:%s\n", desc);
493 /****************************************************************************
495 ****************************************************************************/
496 static void display_group_info5(GROUP_INFO5 *info5)
500 unistr2_to_ascii(temp, &info5->uni_acct_name, sizeof(temp));
501 printf("\tGroup Name:\t%s\n", temp);
502 unistr2_to_ascii(temp, &info5->uni_acct_desc, sizeof(temp));
503 printf("\tDescription:\t%s\n", temp);
504 printf("\tGroup Attribute:%d\n", info5->group_attr);
505 printf("\tNum Members:%d\n", info5->num_members);
508 /****************************************************************************
509 display sam sync structure
510 ****************************************************************************/
511 static void display_group_info_ctr(GROUP_INFO_CTR *ctr)
513 switch (ctr->switch_value1) {
515 display_group_info1(&ctr->group.info1);
518 display_group_info2(&ctr->group.info2);
521 display_group_info3(&ctr->group.info3);
524 display_group_info4(&ctr->group.info4);
527 display_group_info5(&ctr->group.info5);
533 /***********************************************************************
534 * Query group information
536 static NTSTATUS cmd_samr_query_group(struct rpc_pipe_client *cli,
538 int argc, const char **argv)
540 POLICY_HND connect_pol, domain_pol, group_pol;
541 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
542 uint32 info_level = 1;
543 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
544 GROUP_INFO_CTR *group_ctr;
548 if ((argc < 2) || (argc > 4)) {
549 printf("Usage: %s rid [info level] [access mask]\n", argv[0]);
553 sscanf(argv[1], "%i", &group_rid);
556 sscanf(argv[2], "%i", &info_level);
559 sscanf(argv[3], "%x", &access_mask);
561 slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
564 result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
567 if (!NT_STATUS_IS_OK(result))
570 result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
571 MAXIMUM_ALLOWED_ACCESS,
572 &domain_sid, &domain_pol);
574 if (!NT_STATUS_IS_OK(result))
577 result = rpccli_samr_open_group(cli, mem_ctx, &domain_pol,
579 group_rid, &group_pol);
581 if (!NT_STATUS_IS_OK(result))
584 result = rpccli_samr_query_groupinfo(cli, mem_ctx, &group_pol,
585 info_level, &group_ctr);
586 if (!NT_STATUS_IS_OK(result)) {
590 display_group_info_ctr(group_ctr);
592 rpccli_samr_close(cli, mem_ctx, &group_pol);
593 rpccli_samr_close(cli, mem_ctx, &domain_pol);
594 rpccli_samr_close(cli, mem_ctx, &connect_pol);
599 /* Query groups a user is a member of */
601 static NTSTATUS cmd_samr_query_usergroups(struct rpc_pipe_client *cli,
603 int argc, const char **argv)
605 POLICY_HND connect_pol,
608 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
611 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
616 if ((argc < 2) || (argc > 3)) {
617 printf("Usage: %s rid [access mask]\n", argv[0]);
621 sscanf(argv[1], "%i", &user_rid);
624 sscanf(argv[2], "%x", &access_mask);
626 slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
629 result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
632 if (!NT_STATUS_IS_OK(result))
635 result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
636 MAXIMUM_ALLOWED_ACCESS,
637 &domain_sid, &domain_pol);
639 if (!NT_STATUS_IS_OK(result))
642 result = rpccli_samr_open_user(cli, mem_ctx, &domain_pol,
644 user_rid, &user_pol);
646 if (!NT_STATUS_IS_OK(result))
649 result = rpccli_samr_query_usergroups(cli, mem_ctx, &user_pol,
650 &num_groups, &user_gids);
652 if (!NT_STATUS_IS_OK(result))
655 for (i = 0; i < num_groups; i++) {
656 printf("\tgroup rid:[0x%x] attr:[0x%x]\n",
657 user_gids[i].g_rid, user_gids[i].attr);
660 rpccli_samr_close(cli, mem_ctx, &user_pol);
661 rpccli_samr_close(cli, mem_ctx, &domain_pol);
662 rpccli_samr_close(cli, mem_ctx, &connect_pol);
667 /* Query aliases a user is a member of */
669 static NTSTATUS cmd_samr_query_useraliases(struct rpc_pipe_client *cli,
671 int argc, const char **argv)
673 POLICY_HND connect_pol, domain_pol;
674 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
677 uint32 num_aliases, *alias_rids;
678 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
684 printf("Usage: %s builtin|domain sid1 sid2 ...\n", argv[0]);
685 return NT_STATUS_INVALID_PARAMETER;
691 for (i=2; i<argc; i++) {
693 if (!string_to_sid(&tmp_sid, argv[i])) {
694 printf("%s is not a legal SID\n", argv[i]);
695 return NT_STATUS_INVALID_PARAMETER;
697 if (!add_sid_to_array(mem_ctx, &tmp_sid, &sids, &num_sids)) {
698 return NT_STATUS_NO_MEMORY;
703 sid2 = TALLOC_ARRAY(mem_ctx, DOM_SID2, num_sids);
705 return NT_STATUS_NO_MEMORY;
710 for (i=0; i<num_sids; i++) {
711 sid_copy(&sid2[i].sid, &sids[i]);
712 sid2[i].num_auths = sid2[i].sid.num_auths;
715 slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
718 result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
721 if (!NT_STATUS_IS_OK(result))
724 if (StrCaseCmp(argv[1], "domain")==0)
725 result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
727 &domain_sid, &domain_pol);
728 else if (StrCaseCmp(argv[1], "builtin")==0)
729 result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
734 printf("Usage: %s builtin|domain sid1 sid2 ...\n", argv[0]);
735 return NT_STATUS_INVALID_PARAMETER;
738 if (!NT_STATUS_IS_OK(result))
741 result = rpccli_samr_query_useraliases(cli, mem_ctx, &domain_pol,
743 &num_aliases, &alias_rids);
745 if (!NT_STATUS_IS_OK(result))
748 for (i = 0; i < num_aliases; i++) {
749 printf("\tgroup rid:[0x%x]\n", alias_rids[i]);
752 rpccli_samr_close(cli, mem_ctx, &domain_pol);
753 rpccli_samr_close(cli, mem_ctx, &connect_pol);
758 /* Query members of a group */
760 static NTSTATUS cmd_samr_query_groupmem(struct rpc_pipe_client *cli,
762 int argc, const char **argv)
764 POLICY_HND connect_pol, domain_pol, group_pol;
765 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
766 uint32 num_members, *group_rids, *group_attrs, group_rid;
767 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
770 unsigned int old_timeout;
772 if ((argc < 2) || (argc > 3)) {
773 printf("Usage: %s rid [access mask]\n", argv[0]);
777 sscanf(argv[1], "%i", &group_rid);
780 sscanf(argv[2], "%x", &access_mask);
782 slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
785 result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
788 if (!NT_STATUS_IS_OK(result))
791 result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
792 MAXIMUM_ALLOWED_ACCESS,
793 &domain_sid, &domain_pol);
795 if (!NT_STATUS_IS_OK(result))
798 result = rpccli_samr_open_group(cli, mem_ctx, &domain_pol,
800 group_rid, &group_pol);
802 if (!NT_STATUS_IS_OK(result))
805 /* Make sure to wait for our DC's reply */
806 old_timeout = cli_set_timeout(cli->cli, MAX(cli->cli->timeout,30000)); /* 30 seconds. */
808 result = rpccli_samr_query_groupmem(cli, mem_ctx, &group_pol,
809 &num_members, &group_rids,
812 cli_set_timeout(cli->cli, old_timeout);
814 if (!NT_STATUS_IS_OK(result))
817 for (i = 0; i < num_members; i++) {
818 printf("\trid:[0x%x] attr:[0x%x]\n", group_rids[i],
822 rpccli_samr_close(cli, mem_ctx, &group_pol);
823 rpccli_samr_close(cli, mem_ctx, &domain_pol);
824 rpccli_samr_close(cli, mem_ctx, &connect_pol);
829 /* Enumerate domain users */
831 static NTSTATUS cmd_samr_enum_dom_users(struct rpc_pipe_client *cli,
833 int argc, const char **argv)
835 POLICY_HND connect_pol, domain_pol;
836 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
837 uint32 start_idx, size, num_dom_users, i;
840 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
841 uint32 acb_mask = ACB_NORMAL;
842 BOOL got_connect_pol = False, got_domain_pol = False;
844 if ((argc < 1) || (argc > 3)) {
845 printf("Usage: %s [access_mask] [acb_mask]\n", argv[0]);
850 sscanf(argv[1], "%x", &access_mask);
853 sscanf(argv[2], "%x", &acb_mask);
855 /* Get sam policy handle */
857 result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
860 if (!NT_STATUS_IS_OK(result))
863 got_connect_pol = True;
865 /* Get domain policy handle */
867 result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
869 &domain_sid, &domain_pol);
871 if (!NT_STATUS_IS_OK(result))
874 got_domain_pol = True;
876 /* Enumerate domain users */
882 result = rpccli_samr_enum_dom_users(
883 cli, mem_ctx, &domain_pol, &start_idx, acb_mask,
884 size, &dom_users, &dom_rids, &num_dom_users);
886 if (NT_STATUS_IS_OK(result) ||
887 NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES)) {
889 for (i = 0; i < num_dom_users; i++)
890 printf("user:[%s] rid:[0x%x]\n",
891 dom_users[i], dom_rids[i]);
894 } while (NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES));
898 rpccli_samr_close(cli, mem_ctx, &domain_pol);
901 rpccli_samr_close(cli, mem_ctx, &connect_pol);
906 /* Enumerate domain groups */
908 static NTSTATUS cmd_samr_enum_dom_groups(struct rpc_pipe_client *cli,
910 int argc, const char **argv)
912 POLICY_HND connect_pol, domain_pol;
913 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
914 uint32 start_idx, size, num_dom_groups, i;
915 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
916 struct acct_info *dom_groups;
917 BOOL got_connect_pol = False, got_domain_pol = False;
919 if ((argc < 1) || (argc > 2)) {
920 printf("Usage: %s [access_mask]\n", argv[0]);
925 sscanf(argv[1], "%x", &access_mask);
927 /* Get sam policy handle */
929 result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
932 if (!NT_STATUS_IS_OK(result))
935 got_connect_pol = True;
937 /* Get domain policy handle */
939 result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
941 &domain_sid, &domain_pol);
943 if (!NT_STATUS_IS_OK(result))
946 got_domain_pol = True;
948 /* Enumerate domain groups */
954 result = rpccli_samr_enum_dom_groups(
955 cli, mem_ctx, &domain_pol, &start_idx, size,
956 &dom_groups, &num_dom_groups);
958 if (NT_STATUS_IS_OK(result) ||
959 NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES)) {
961 for (i = 0; i < num_dom_groups; i++)
962 printf("group:[%s] rid:[0x%x]\n",
963 dom_groups[i].acct_name,
967 } while (NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES));
971 rpccli_samr_close(cli, mem_ctx, &domain_pol);
974 rpccli_samr_close(cli, mem_ctx, &connect_pol);
979 /* Enumerate alias groups */
981 static NTSTATUS cmd_samr_enum_als_groups(struct rpc_pipe_client *cli,
983 int argc, const char **argv)
985 POLICY_HND connect_pol, domain_pol;
986 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
987 uint32 start_idx, size, num_als_groups, i;
988 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
989 struct acct_info *als_groups;
990 BOOL got_connect_pol = False, got_domain_pol = False;
992 if ((argc < 2) || (argc > 3)) {
993 printf("Usage: %s builtin|domain [access mask]\n", argv[0]);
998 sscanf(argv[2], "%x", &access_mask);
1000 /* Get sam policy handle */
1002 result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
1005 if (!NT_STATUS_IS_OK(result))
1008 got_connect_pol = True;
1010 /* Get domain policy handle */
1012 if (StrCaseCmp(argv[1], "domain")==0)
1013 result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
1015 &domain_sid, &domain_pol);
1016 else if (StrCaseCmp(argv[1], "builtin")==0)
1017 result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
1019 &global_sid_Builtin, &domain_pol);
1021 return NT_STATUS_OK;
1023 if (!NT_STATUS_IS_OK(result))
1026 got_domain_pol = True;
1028 /* Enumerate alias groups */
1031 size = 0xffff; /* Number of groups to retrieve */
1034 result = rpccli_samr_enum_als_groups(
1035 cli, mem_ctx, &domain_pol, &start_idx, size,
1036 &als_groups, &num_als_groups);
1038 if (NT_STATUS_IS_OK(result) ||
1039 NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES)) {
1041 for (i = 0; i < num_als_groups; i++)
1042 printf("group:[%s] rid:[0x%x]\n",
1043 als_groups[i].acct_name,
1046 } while (NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES));
1050 rpccli_samr_close(cli, mem_ctx, &domain_pol);
1052 if (got_connect_pol)
1053 rpccli_samr_close(cli, mem_ctx, &connect_pol);
1058 /* Query alias membership */
1060 static NTSTATUS cmd_samr_query_aliasmem(struct rpc_pipe_client *cli,
1061 TALLOC_CTX *mem_ctx,
1062 int argc, const char **argv)
1064 POLICY_HND connect_pol, domain_pol, alias_pol;
1065 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
1066 uint32 alias_rid, num_members, i;
1067 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
1068 DOM_SID *alias_sids;
1070 if ((argc < 3) || (argc > 4)) {
1071 printf("Usage: %s builtin|domain rid [access mask]\n", argv[0]);
1072 return NT_STATUS_OK;
1075 sscanf(argv[2], "%i", &alias_rid);
1078 sscanf(argv[3], "%x", &access_mask);
1080 /* Open SAMR handle */
1082 result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
1085 if (!NT_STATUS_IS_OK(result))
1088 /* Open handle on domain */
1090 if (StrCaseCmp(argv[1], "domain")==0)
1091 result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
1092 MAXIMUM_ALLOWED_ACCESS,
1093 &domain_sid, &domain_pol);
1094 else if (StrCaseCmp(argv[1], "builtin")==0)
1095 result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
1096 MAXIMUM_ALLOWED_ACCESS,
1097 &global_sid_Builtin, &domain_pol);
1099 return NT_STATUS_OK;
1101 if (!NT_STATUS_IS_OK(result))
1104 /* Open handle on alias */
1106 result = rpccli_samr_open_alias(cli, mem_ctx, &domain_pol,
1108 alias_rid, &alias_pol);
1109 if (!NT_STATUS_IS_OK(result))
1112 result = rpccli_samr_query_aliasmem(cli, mem_ctx, &alias_pol,
1113 &num_members, &alias_sids);
1115 if (!NT_STATUS_IS_OK(result))
1118 for (i = 0; i < num_members; i++) {
1121 sid_to_string(sid_str, &alias_sids[i]);
1122 printf("\tsid:[%s]\n", sid_str);
1125 rpccli_samr_close(cli, mem_ctx, &alias_pol);
1126 rpccli_samr_close(cli, mem_ctx, &domain_pol);
1127 rpccli_samr_close(cli, mem_ctx, &connect_pol);
1132 /* Query delete an alias membership */
1134 static NTSTATUS cmd_samr_delete_alias(struct rpc_pipe_client *cli,
1135 TALLOC_CTX *mem_ctx,
1136 int argc, const char **argv)
1138 POLICY_HND connect_pol, domain_pol, alias_pol;
1139 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
1141 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
1144 printf("Usage: %s builtin|domain [rid|name]\n", argv[0]);
1145 return NT_STATUS_OK;
1148 alias_rid = strtoul(argv[2], NULL, 10);
1150 /* Open SAMR handle */
1152 result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
1155 if (!NT_STATUS_IS_OK(result))
1158 /* Open handle on domain */
1160 if (StrCaseCmp(argv[1], "domain")==0)
1161 result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
1162 MAXIMUM_ALLOWED_ACCESS,
1163 &domain_sid, &domain_pol);
1164 else if (StrCaseCmp(argv[1], "builtin")==0)
1165 result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
1166 MAXIMUM_ALLOWED_ACCESS,
1167 &global_sid_Builtin, &domain_pol);
1169 return NT_STATUS_INVALID_PARAMETER;
1171 if (!NT_STATUS_IS_OK(result))
1174 /* Open handle on alias */
1176 result = rpccli_samr_open_alias(cli, mem_ctx, &domain_pol,
1178 alias_rid, &alias_pol);
1179 if (!NT_STATUS_IS_OK(result) && (alias_rid == 0)) {
1180 /* Probably this was a user name, try lookupnames */
1182 uint32 *rids, *types;
1184 result = rpccli_samr_lookup_names(cli, mem_ctx, &domain_pol,
1189 if (NT_STATUS_IS_OK(result)) {
1190 result = rpccli_samr_open_alias(cli, mem_ctx,
1193 rids[0], &alias_pol);
1197 result = rpccli_samr_delete_dom_alias(cli, mem_ctx, &alias_pol);
1199 if (!NT_STATUS_IS_OK(result))
1202 rpccli_samr_close(cli, mem_ctx, &domain_pol);
1203 rpccli_samr_close(cli, mem_ctx, &connect_pol);
1208 /* Query display info */
1210 static NTSTATUS cmd_samr_query_dispinfo_int(struct rpc_pipe_client *cli,
1211 TALLOC_CTX *mem_ctx,
1212 int argc, const char **argv,
1215 POLICY_HND connect_pol, domain_pol;
1216 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
1217 uint32 start_idx=0, max_entries=250, max_size = (uint32) -1, num_entries, i;
1218 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
1219 uint32 info_level = 1;
1220 SAM_DISPINFO_CTR ctr;
1221 SAM_DISPINFO_1 info1;
1222 SAM_DISPINFO_2 info2;
1223 SAM_DISPINFO_3 info3;
1224 SAM_DISPINFO_4 info4;
1225 SAM_DISPINFO_5 info5;
1227 BOOL got_params = False; /* Use get_query_dispinfo_params() or not? */
1230 printf("Usage: %s [info level] [start index] [max entries] [max size] [access mask]\n", argv[0]);
1231 return NT_STATUS_OK;
1235 sscanf(argv[1], "%i", &info_level);
1238 sscanf(argv[2], "%i", &start_idx);
1241 sscanf(argv[3], "%i", &max_entries);
1246 sscanf(argv[4], "%i", &max_size);
1251 sscanf(argv[5], "%x", &access_mask);
1254 /* Get sam policy handle */
1256 result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
1259 if (!NT_STATUS_IS_OK(result))
1262 /* Get domain policy handle */
1264 result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
1266 &domain_sid, &domain_pol);
1268 if (!NT_STATUS_IS_OK(result))
1271 /* Query display info */
1276 switch (info_level) {
1279 ctr.sam.info1 = &info1;
1283 ctr.sam.info2 = &info2;
1287 ctr.sam.info3 = &info3;
1291 ctr.sam.info4 = &info4;
1295 ctr.sam.info5 = &info5;
1303 get_query_dispinfo_params(
1304 loop_count, &max_entries, &max_size);
1307 case SAMR_QUERY_DISPINFO:
1308 result = rpccli_samr_query_dispinfo(cli, mem_ctx, &domain_pol,
1309 &start_idx, info_level,
1310 &num_entries, max_entries,
1313 case SAMR_QUERY_DISPINFO2:
1314 result = rpccli_samr_query_dispinfo2(cli, mem_ctx, &domain_pol,
1315 &start_idx, info_level,
1316 &num_entries, max_entries,
1319 case SAMR_QUERY_DISPINFO3:
1320 result = rpccli_samr_query_dispinfo3(cli, mem_ctx, &domain_pol,
1321 &start_idx, info_level,
1322 &num_entries, max_entries,
1326 printf("unknown opcode: %d\n", opcode);
1327 return NT_STATUS_INVALID_PARAMETER;
1333 if (NT_STATUS_IS_ERR(result))
1336 if (num_entries == 0)
1339 for (i = 0; i < num_entries; i++) {
1340 switch (info_level) {
1342 display_sam_info_1(&ctr.sam.info1->sam[i], &ctr.sam.info1->str[i]);
1345 display_sam_info_2(&ctr.sam.info2->sam[i], &ctr.sam.info2->str[i]);
1348 display_sam_info_3(&ctr.sam.info3->sam[i], &ctr.sam.info3->str[i]);
1351 display_sam_info_4(&ctr.sam.info4->sam[i], &ctr.sam.info4->str[i]);
1354 display_sam_info_5(&ctr.sam.info5->sam[i], &ctr.sam.info5->str[i]);
1358 } while ( NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES));
1360 rpccli_samr_close(cli, mem_ctx, &domain_pol);
1361 rpccli_samr_close(cli, mem_ctx, &connect_pol);
1366 static NTSTATUS cmd_samr_query_dispinfo(struct rpc_pipe_client *cli,
1367 TALLOC_CTX *mem_ctx,
1368 int argc, const char **argv)
1370 return cmd_samr_query_dispinfo_int(cli, mem_ctx, argc, argv, SAMR_QUERY_DISPINFO);
1373 static NTSTATUS cmd_samr_query_dispinfo2(struct rpc_pipe_client *cli,
1374 TALLOC_CTX *mem_ctx,
1375 int argc, const char **argv)
1377 return cmd_samr_query_dispinfo_int(cli, mem_ctx, argc, argv, SAMR_QUERY_DISPINFO2);
1380 static NTSTATUS cmd_samr_query_dispinfo3(struct rpc_pipe_client *cli,
1381 TALLOC_CTX *mem_ctx,
1382 int argc, const char **argv)
1384 return cmd_samr_query_dispinfo_int(cli, mem_ctx, argc, argv, SAMR_QUERY_DISPINFO3);
1387 /* Query display info index */
1389 static NTSTATUS cmd_samr_get_dispenum_index_int(struct rpc_pipe_client *cli,
1390 TALLOC_CTX *mem_ctx,
1391 int argc, const char **argv,
1394 POLICY_HND connect_pol, domain_pol;
1395 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
1396 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
1397 uint16 info_level = 1;
1400 if (argc < 2 || argc > 3) {
1401 printf("Usage: %s name [info level]\n", argv[0]);
1402 return NT_STATUS_OK;
1406 sscanf(argv[2], "%hd", &info_level);
1409 /* Get sam policy handle */
1411 result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
1414 if (!NT_STATUS_IS_OK(result)) {
1418 /* Get domain policy handle */
1420 result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
1422 &domain_sid, &domain_pol);
1424 if (!NT_STATUS_IS_OK(result)) {
1428 /* Query display info index */
1431 case SAMR_GET_DISPENUM_INDEX:
1432 result = rpccli_samr_get_dispenum_index(cli, mem_ctx, &domain_pol,
1433 info_level, argv[1], &idx);
1435 case SAMR_GET_DISPENUM_INDEX2:
1436 result = rpccli_samr_get_dispenum_index2(cli, mem_ctx, &domain_pol,
1437 info_level, argv[1], &idx);
1440 printf("unknown opcode\n");
1441 return NT_STATUS_INVALID_PARAMETER;
1444 if (NT_STATUS_IS_ERR(result)) {
1448 printf("idx is: %d (0x%08x)\n", idx, idx);
1450 rpccli_samr_close(cli, mem_ctx, &domain_pol);
1451 rpccli_samr_close(cli, mem_ctx, &connect_pol);
1456 /* Query display info index */
1458 static NTSTATUS cmd_samr_get_dispenum_index(struct rpc_pipe_client *cli,
1459 TALLOC_CTX *mem_ctx,
1460 int argc, const char **argv)
1462 return cmd_samr_get_dispenum_index_int(cli, mem_ctx, argc, argv, SAMR_GET_DISPENUM_INDEX);
1465 /* Query display info index2 */
1467 static NTSTATUS cmd_samr_get_dispenum_index2(struct rpc_pipe_client *cli,
1468 TALLOC_CTX *mem_ctx,
1469 int argc, const char **argv)
1471 return cmd_samr_get_dispenum_index_int(cli, mem_ctx, argc, argv, SAMR_GET_DISPENUM_INDEX2);
1474 /* Query domain info */
1476 static NTSTATUS cmd_samr_query_dominfo(struct rpc_pipe_client *cli,
1477 TALLOC_CTX *mem_ctx,
1478 int argc, const char **argv)
1480 POLICY_HND connect_pol, domain_pol;
1481 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
1482 uint32 switch_level = 2;
1483 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
1487 printf("Usage: %s [info level] [access mask]\n", argv[0]);
1488 return NT_STATUS_OK;
1492 sscanf(argv[1], "%i", &switch_level);
1495 sscanf(argv[2], "%x", &access_mask);
1497 /* Get sam policy handle */
1499 result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
1502 if (!NT_STATUS_IS_OK(result))
1505 /* Get domain policy handle */
1507 result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
1509 &domain_sid, &domain_pol);
1511 if (!NT_STATUS_IS_OK(result))
1514 /* Query domain info */
1516 result = rpccli_samr_query_dom_info(cli, mem_ctx, &domain_pol,
1517 switch_level, &ctr);
1519 if (!NT_STATUS_IS_OK(result))
1522 /* Display domain info */
1524 switch (switch_level) {
1526 display_sam_unk_info_1(&ctr.info.inf1);
1529 display_sam_unk_info_2(&ctr.info.inf2);
1532 display_sam_unk_info_3(&ctr.info.inf3);
1535 display_sam_unk_info_4(&ctr.info.inf4);
1538 display_sam_unk_info_5(&ctr.info.inf5);
1541 display_sam_unk_info_6(&ctr.info.inf6);
1544 display_sam_unk_info_7(&ctr.info.inf7);
1547 display_sam_unk_info_8(&ctr.info.inf8);
1550 display_sam_unk_info_9(&ctr.info.inf9);
1553 display_sam_unk_info_12(&ctr.info.inf12);
1556 display_sam_unk_info_13(&ctr.info.inf13);
1560 printf("cannot display domain info for switch value %d\n",
1567 rpccli_samr_close(cli, mem_ctx, &domain_pol);
1568 rpccli_samr_close(cli, mem_ctx, &connect_pol);
1572 /* Create domain user */
1574 static NTSTATUS cmd_samr_create_dom_user(struct rpc_pipe_client *cli,
1575 TALLOC_CTX *mem_ctx,
1576 int argc, const char **argv)
1578 POLICY_HND connect_pol, domain_pol, user_pol;
1579 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
1580 const char *acct_name;
1582 uint32 unknown, user_rid;
1583 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
1585 if ((argc < 2) || (argc > 3)) {
1586 printf("Usage: %s username [access mask]\n", argv[0]);
1587 return NT_STATUS_OK;
1590 acct_name = argv[1];
1593 sscanf(argv[2], "%x", &access_mask);
1595 /* Get sam policy handle */
1597 result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
1600 if (!NT_STATUS_IS_OK(result))
1603 /* Get domain policy handle */
1605 result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
1607 &domain_sid, &domain_pol);
1609 if (!NT_STATUS_IS_OK(result))
1612 /* Create domain user */
1614 acb_info = ACB_NORMAL;
1615 unknown = 0xe005000b; /* No idea what this is - a permission mask? */
1617 result = rpccli_samr_create_dom_user(cli, mem_ctx, &domain_pol,
1618 acct_name, acb_info, unknown,
1619 &user_pol, &user_rid);
1621 if (!NT_STATUS_IS_OK(result))
1624 result = rpccli_samr_close(cli, mem_ctx, &user_pol);
1625 if (!NT_STATUS_IS_OK(result)) goto done;
1627 result = rpccli_samr_close(cli, mem_ctx, &domain_pol);
1628 if (!NT_STATUS_IS_OK(result)) goto done;
1630 result = rpccli_samr_close(cli, mem_ctx, &connect_pol);
1631 if (!NT_STATUS_IS_OK(result)) goto done;
1637 /* Create domain group */
1639 static NTSTATUS cmd_samr_create_dom_group(struct rpc_pipe_client *cli,
1640 TALLOC_CTX *mem_ctx,
1641 int argc, const char **argv)
1643 POLICY_HND connect_pol, domain_pol, group_pol;
1644 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
1645 const char *grp_name;
1646 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
1648 if ((argc < 2) || (argc > 3)) {
1649 printf("Usage: %s groupname [access mask]\n", argv[0]);
1650 return NT_STATUS_OK;
1656 sscanf(argv[2], "%x", &access_mask);
1658 /* Get sam policy handle */
1660 result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
1663 if (!NT_STATUS_IS_OK(result))
1666 /* Get domain policy handle */
1668 result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
1670 &domain_sid, &domain_pol);
1672 if (!NT_STATUS_IS_OK(result))
1675 /* Create domain user */
1677 result = rpccli_samr_create_dom_group(cli, mem_ctx, &domain_pol,
1678 grp_name, MAXIMUM_ALLOWED_ACCESS,
1681 if (!NT_STATUS_IS_OK(result))
1684 result = rpccli_samr_close(cli, mem_ctx, &group_pol);
1685 if (!NT_STATUS_IS_OK(result)) goto done;
1687 result = rpccli_samr_close(cli, mem_ctx, &domain_pol);
1688 if (!NT_STATUS_IS_OK(result)) goto done;
1690 result = rpccli_samr_close(cli, mem_ctx, &connect_pol);
1691 if (!NT_STATUS_IS_OK(result)) goto done;
1697 /* Create domain alias */
1699 static NTSTATUS cmd_samr_create_dom_alias(struct rpc_pipe_client *cli,
1700 TALLOC_CTX *mem_ctx,
1701 int argc, const char **argv)
1703 POLICY_HND connect_pol, domain_pol, alias_pol;
1704 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
1705 const char *alias_name;
1706 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
1708 if ((argc < 2) || (argc > 3)) {
1709 printf("Usage: %s aliasname [access mask]\n", argv[0]);
1710 return NT_STATUS_OK;
1713 alias_name = argv[1];
1716 sscanf(argv[2], "%x", &access_mask);
1718 /* Get sam policy handle */
1720 result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
1723 if (!NT_STATUS_IS_OK(result))
1726 /* Get domain policy handle */
1728 result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
1730 &domain_sid, &domain_pol);
1732 if (!NT_STATUS_IS_OK(result))
1735 /* Create domain user */
1737 result = rpccli_samr_create_dom_alias(cli, mem_ctx, &domain_pol,
1738 alias_name, &alias_pol);
1740 if (!NT_STATUS_IS_OK(result))
1743 result = rpccli_samr_close(cli, mem_ctx, &alias_pol);
1744 if (!NT_STATUS_IS_OK(result)) goto done;
1746 result = rpccli_samr_close(cli, mem_ctx, &domain_pol);
1747 if (!NT_STATUS_IS_OK(result)) goto done;
1749 result = rpccli_samr_close(cli, mem_ctx, &connect_pol);
1750 if (!NT_STATUS_IS_OK(result)) goto done;
1756 /* Lookup sam names */
1758 static NTSTATUS cmd_samr_lookup_names(struct rpc_pipe_client *cli,
1759 TALLOC_CTX *mem_ctx,
1760 int argc, const char **argv)
1762 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
1763 POLICY_HND connect_pol, domain_pol;
1764 uint32 flags = 0x000003e8; /* Unknown */
1765 uint32 num_rids, num_names, *name_types, *rids;
1770 printf("Usage: %s domain|builtin name1 [name2 [name3] [...]]\n", argv[0]);
1771 printf("check on the domain SID: S-1-5-21-x-y-z\n");
1772 printf("or check on the builtin SID: S-1-5-32\n");
1773 return NT_STATUS_OK;
1776 /* Get sam policy and domain handles */
1778 result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
1781 if (!NT_STATUS_IS_OK(result))
1784 if (StrCaseCmp(argv[1], "domain")==0)
1785 result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
1786 MAXIMUM_ALLOWED_ACCESS,
1787 &domain_sid, &domain_pol);
1788 else if (StrCaseCmp(argv[1], "builtin")==0)
1789 result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
1790 MAXIMUM_ALLOWED_ACCESS,
1791 &global_sid_Builtin, &domain_pol);
1793 return NT_STATUS_OK;
1795 if (!NT_STATUS_IS_OK(result))
1800 num_names = argc - 2;
1802 if ((names = TALLOC_ARRAY(mem_ctx, const char *, num_names)) == NULL) {
1803 rpccli_samr_close(cli, mem_ctx, &domain_pol);
1804 rpccli_samr_close(cli, mem_ctx, &connect_pol);
1805 result = NT_STATUS_NO_MEMORY;
1809 for (i = 0; i < num_names; i++)
1810 names[i] = argv[i + 2];
1812 result = rpccli_samr_lookup_names(cli, mem_ctx, &domain_pol,
1813 flags, num_names, names,
1814 &num_rids, &rids, &name_types);
1816 if (!NT_STATUS_IS_OK(result))
1819 /* Display results */
1821 for (i = 0; i < num_names; i++)
1822 printf("name %s: 0x%x (%d)\n", names[i], rids[i],
1825 rpccli_samr_close(cli, mem_ctx, &domain_pol);
1826 rpccli_samr_close(cli, mem_ctx, &connect_pol);
1831 /* Lookup sam rids */
1833 static NTSTATUS cmd_samr_lookup_rids(struct rpc_pipe_client *cli,
1834 TALLOC_CTX *mem_ctx,
1835 int argc, const char **argv)
1837 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
1838 POLICY_HND connect_pol, domain_pol;
1839 uint32 num_rids, num_names, *rids, *name_types;
1844 printf("Usage: %s domain|builtin rid1 [rid2 [rid3] [...]]\n", argv[0]);
1845 return NT_STATUS_OK;
1848 /* Get sam policy and domain handles */
1850 result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
1853 if (!NT_STATUS_IS_OK(result))
1856 if (StrCaseCmp(argv[1], "domain")==0)
1857 result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
1858 MAXIMUM_ALLOWED_ACCESS,
1859 &domain_sid, &domain_pol);
1860 else if (StrCaseCmp(argv[1], "builtin")==0)
1861 result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
1862 MAXIMUM_ALLOWED_ACCESS,
1863 &global_sid_Builtin, &domain_pol);
1865 return NT_STATUS_OK;
1867 if (!NT_STATUS_IS_OK(result))
1872 num_rids = argc - 2;
1874 if ((rids = TALLOC_ARRAY(mem_ctx, uint32, num_rids)) == NULL) {
1875 rpccli_samr_close(cli, mem_ctx, &domain_pol);
1876 rpccli_samr_close(cli, mem_ctx, &connect_pol);
1877 result = NT_STATUS_NO_MEMORY;
1881 for (i = 0; i < argc - 2; i++)
1882 sscanf(argv[i + 2], "%i", &rids[i]);
1884 result = rpccli_samr_lookup_rids(cli, mem_ctx, &domain_pol, num_rids, rids,
1885 &num_names, &names, &name_types);
1887 if (!NT_STATUS_IS_OK(result) &&
1888 !NT_STATUS_EQUAL(result, STATUS_SOME_UNMAPPED))
1891 /* Display results */
1893 for (i = 0; i < num_names; i++)
1894 printf("rid 0x%x: %s (%d)\n", rids[i], names[i], name_types[i]);
1896 rpccli_samr_close(cli, mem_ctx, &domain_pol);
1897 rpccli_samr_close(cli, mem_ctx, &connect_pol);
1902 /* Delete domain group */
1904 static NTSTATUS cmd_samr_delete_dom_group(struct rpc_pipe_client *cli,
1905 TALLOC_CTX *mem_ctx,
1906 int argc, const char **argv)
1908 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
1909 POLICY_HND connect_pol, domain_pol, group_pol;
1910 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
1912 if ((argc < 2) || (argc > 3)) {
1913 printf("Usage: %s groupname\n", argv[0]);
1914 return NT_STATUS_OK;
1918 sscanf(argv[2], "%x", &access_mask);
1920 /* Get sam policy and domain handles */
1922 result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
1925 if (!NT_STATUS_IS_OK(result))
1928 result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
1929 MAXIMUM_ALLOWED_ACCESS,
1930 &domain_sid, &domain_pol);
1932 if (!NT_STATUS_IS_OK(result))
1935 /* Get handle on group */
1938 uint32 *group_rids, num_rids, *name_types;
1939 uint32 flags = 0x000003e8; /* Unknown */
1941 result = rpccli_samr_lookup_names(cli, mem_ctx, &domain_pol,
1942 flags, 1, (const char **)&argv[1],
1943 &num_rids, &group_rids,
1946 if (!NT_STATUS_IS_OK(result))
1949 result = rpccli_samr_open_group(cli, mem_ctx, &domain_pol,
1951 group_rids[0], &group_pol);
1953 if (!NT_STATUS_IS_OK(result))
1959 result = rpccli_samr_delete_dom_group(cli, mem_ctx, &group_pol);
1961 if (!NT_STATUS_IS_OK(result))
1964 /* Display results */
1966 rpccli_samr_close(cli, mem_ctx, &group_pol);
1967 rpccli_samr_close(cli, mem_ctx, &domain_pol);
1968 rpccli_samr_close(cli, mem_ctx, &connect_pol);
1974 /* Delete domain user */
1976 static NTSTATUS cmd_samr_delete_dom_user(struct rpc_pipe_client *cli,
1977 TALLOC_CTX *mem_ctx,
1978 int argc, const char **argv)
1980 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
1981 POLICY_HND connect_pol, domain_pol, user_pol;
1982 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
1984 if ((argc < 2) || (argc > 3)) {
1985 printf("Usage: %s username\n", argv[0]);
1986 return NT_STATUS_OK;
1990 sscanf(argv[2], "%x", &access_mask);
1992 /* Get sam policy and domain handles */
1994 result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
1997 if (!NT_STATUS_IS_OK(result))
2000 result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
2001 MAXIMUM_ALLOWED_ACCESS,
2002 &domain_sid, &domain_pol);
2004 if (!NT_STATUS_IS_OK(result))
2007 /* Get handle on user */
2010 uint32 *user_rids, num_rids, *name_types;
2011 uint32 flags = 0x000003e8; /* Unknown */
2013 result = rpccli_samr_lookup_names(cli, mem_ctx, &domain_pol,
2014 flags, 1, (const char **)&argv[1],
2015 &num_rids, &user_rids,
2018 if (!NT_STATUS_IS_OK(result))
2021 result = rpccli_samr_open_user(cli, mem_ctx, &domain_pol,
2023 user_rids[0], &user_pol);
2025 if (!NT_STATUS_IS_OK(result))
2031 result = rpccli_samr_delete_dom_user(cli, mem_ctx, &user_pol);
2033 if (!NT_STATUS_IS_OK(result))
2036 /* Display results */
2038 rpccli_samr_close(cli, mem_ctx, &user_pol);
2039 rpccli_samr_close(cli, mem_ctx, &domain_pol);
2040 rpccli_samr_close(cli, mem_ctx, &connect_pol);
2046 /**********************************************************************
2047 * Query user security object
2049 static NTSTATUS cmd_samr_query_sec_obj(struct rpc_pipe_client *cli,
2050 TALLOC_CTX *mem_ctx,
2051 int argc, const char **argv)
2053 POLICY_HND connect_pol, domain_pol, user_pol, *pol;
2054 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
2055 uint32 sec_info = DACL_SECURITY_INFORMATION;
2057 uint32 user_rid = 0;
2058 TALLOC_CTX *ctx = NULL;
2059 SEC_DESC_BUF *sec_desc_buf=NULL;
2060 BOOL domain = False;
2062 ctx=talloc_init("cmd_samr_query_sec_obj");
2064 if ((argc < 1) || (argc > 3)) {
2065 printf("Usage: %s [rid|-d] [sec_info]\n", argv[0]);
2066 printf("\tSpecify rid for security on user, -d for security on domain\n");
2067 talloc_destroy(ctx);
2068 return NT_STATUS_OK;
2072 if (strcmp(argv[1], "-d") == 0)
2075 sscanf(argv[1], "%i", &user_rid);
2079 sec_info = atoi(argv[2]);
2082 slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
2084 result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
2087 if (!NT_STATUS_IS_OK(result))
2090 if (domain || user_rid)
2091 result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
2092 MAXIMUM_ALLOWED_ACCESS,
2093 &domain_sid, &domain_pol);
2095 if (!NT_STATUS_IS_OK(result))
2099 result = rpccli_samr_open_user(cli, mem_ctx, &domain_pol,
2100 MAXIMUM_ALLOWED_ACCESS,
2101 user_rid, &user_pol);
2103 if (!NT_STATUS_IS_OK(result))
2106 /* Pick which query pol to use */
2116 /* Query SAM security object */
2118 result = rpccli_samr_query_sec_obj(cli, mem_ctx, pol, sec_info, ctx,
2121 if (!NT_STATUS_IS_OK(result))
2124 display_sec_desc(sec_desc_buf->sd);
2126 rpccli_samr_close(cli, mem_ctx, &user_pol);
2127 rpccli_samr_close(cli, mem_ctx, &domain_pol);
2128 rpccli_samr_close(cli, mem_ctx, &connect_pol);
2130 talloc_destroy(ctx);
2134 static NTSTATUS cmd_samr_get_usrdom_pwinfo(struct rpc_pipe_client *cli,
2135 TALLOC_CTX *mem_ctx,
2136 int argc, const char **argv)
2138 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
2139 POLICY_HND connect_pol, domain_pol, user_pol;
2140 uint16 min_pwd_length;
2141 uint32 password_properties, unknown1, rid;
2144 printf("Usage: %s rid\n", argv[0]);
2145 return NT_STATUS_OK;
2148 sscanf(argv[1], "%i", &rid);
2150 result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
2153 if (!NT_STATUS_IS_OK(result)) {
2157 result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
2158 MAXIMUM_ALLOWED_ACCESS, &domain_sid, &domain_pol);
2160 if (!NT_STATUS_IS_OK(result)) {
2164 result = rpccli_samr_open_user(cli, mem_ctx, &domain_pol,
2165 MAXIMUM_ALLOWED_ACCESS,
2168 if (!NT_STATUS_IS_OK(result)) {
2172 result = rpccli_samr_get_usrdom_pwinfo(cli, mem_ctx, &user_pol,
2173 &min_pwd_length, &password_properties,
2176 if (NT_STATUS_IS_OK(result)) {
2177 printf("min_pwd_length: %d\n", min_pwd_length);
2178 printf("unknown1: %d\n", unknown1);
2179 display_password_properties(password_properties);
2183 rpccli_samr_close(cli, mem_ctx, &user_pol);
2184 rpccli_samr_close(cli, mem_ctx, &domain_pol);
2185 rpccli_samr_close(cli, mem_ctx, &connect_pol);
2191 static NTSTATUS cmd_samr_get_dom_pwinfo(struct rpc_pipe_client *cli,
2192 TALLOC_CTX *mem_ctx,
2193 int argc, const char **argv)
2195 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
2196 uint16 min_pwd_length;
2197 uint32 password_properties;
2200 printf("Usage: %s\n", argv[0]);
2201 return NT_STATUS_OK;
2204 result = rpccli_samr_get_dom_pwinfo(cli, mem_ctx, &min_pwd_length, &password_properties) ;
2206 if (NT_STATUS_IS_OK(result)) {
2207 printf("min_pwd_length: %d\n", min_pwd_length);
2208 display_password_properties(password_properties);
2214 /* Look up domain name */
2216 static NTSTATUS cmd_samr_lookup_domain(struct rpc_pipe_client *cli,
2217 TALLOC_CTX *mem_ctx,
2218 int argc, const char **argv)
2220 POLICY_HND connect_pol, domain_pol;
2221 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
2222 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
2223 fstring domain_name,sid_string;
2227 printf("Usage: %s domain_name\n", argv[0]);
2228 return NT_STATUS_OK;
2231 sscanf(argv[1], "%s", domain_name);
2233 result = try_samr_connects(cli, mem_ctx, access_mask, &connect_pol);
2235 if (!NT_STATUS_IS_OK(result))
2238 result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
2239 access_mask, &domain_sid, &domain_pol);
2241 if (!NT_STATUS_IS_OK(result))
2244 result = rpccli_samr_lookup_domain(
2245 cli, mem_ctx, &connect_pol, domain_name, &sid);
2247 sid_to_string(sid_string,&sid);
2249 if (NT_STATUS_IS_OK(result))
2250 printf("SAMR_LOOKUP_DOMAIN: Domain Name: %s Domain SID: %s\n",
2251 domain_name,sid_string);
2253 rpccli_samr_close(cli, mem_ctx, &domain_pol);
2254 rpccli_samr_close(cli, mem_ctx, &connect_pol);
2259 /* Change user password */
2261 static NTSTATUS cmd_samr_chgpasswd2(struct rpc_pipe_client *cli,
2262 TALLOC_CTX *mem_ctx,
2263 int argc, const char **argv)
2265 POLICY_HND connect_pol, domain_pol;
2266 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
2267 const char *user, *oldpass, *newpass;
2268 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
2271 printf("Usage: %s username oldpass newpass\n", argv[0]);
2272 return NT_STATUS_INVALID_PARAMETER;
2279 /* Get sam policy handle */
2281 result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
2284 if (!NT_STATUS_IS_OK(result))
2287 /* Get domain policy handle */
2289 result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
2291 &domain_sid, &domain_pol);
2293 if (!NT_STATUS_IS_OK(result))
2296 /* Change user password */
2297 result = rpccli_samr_chgpasswd_user(cli, mem_ctx, user, newpass, oldpass);
2299 if (!NT_STATUS_IS_OK(result))
2302 result = rpccli_samr_close(cli, mem_ctx, &domain_pol);
2303 if (!NT_STATUS_IS_OK(result)) goto done;
2305 result = rpccli_samr_close(cli, mem_ctx, &connect_pol);
2306 if (!NT_STATUS_IS_OK(result)) goto done;
2313 /* Change user password */
2315 static NTSTATUS cmd_samr_chgpasswd3(struct rpc_pipe_client *cli,
2316 TALLOC_CTX *mem_ctx,
2317 int argc, const char **argv)
2319 POLICY_HND connect_pol, domain_pol;
2320 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
2321 const char *user, *oldpass, *newpass;
2322 uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
2323 SAM_UNK_INFO_1 info;
2324 SAMR_CHANGE_REJECT reject;
2327 printf("Usage: %s username oldpass newpass\n", argv[0]);
2328 return NT_STATUS_INVALID_PARAMETER;
2335 /* Get sam policy handle */
2337 result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
2340 if (!NT_STATUS_IS_OK(result))
2343 /* Get domain policy handle */
2345 result = rpccli_samr_open_domain(cli, mem_ctx, &connect_pol,
2347 &domain_sid, &domain_pol);
2349 if (!NT_STATUS_IS_OK(result))
2352 /* Change user password */
2353 result = rpccli_samr_chgpasswd3(cli, mem_ctx, user, newpass, oldpass, &info, &reject);
2355 if (NT_STATUS_EQUAL(result, NT_STATUS_PASSWORD_RESTRICTION)) {
2357 display_sam_unk_info_1(&info);
2359 switch (reject.reject_reason) {
2360 case REJECT_REASON_TOO_SHORT:
2361 d_printf("REJECT_REASON_TOO_SHORT\n");
2363 case REJECT_REASON_IN_HISTORY:
2364 d_printf("REJECT_REASON_IN_HISTORY\n");
2366 case REJECT_REASON_NOT_COMPLEX:
2367 d_printf("REJECT_REASON_NOT_COMPLEX\n");
2369 case REJECT_REASON_OTHER:
2370 d_printf("REJECT_REASON_OTHER\n");
2373 d_printf("unknown reject reason: %d\n", reject.reject_reason);
2378 if (!NT_STATUS_IS_OK(result))
2381 result = rpccli_samr_close(cli, mem_ctx, &domain_pol);
2382 if (!NT_STATUS_IS_OK(result)) goto done;
2384 result = rpccli_samr_close(cli, mem_ctx, &connect_pol);
2385 if (!NT_STATUS_IS_OK(result)) goto done;
2391 /* List of commands exported by this module */
2393 struct cmd_set samr_commands[] = {
2397 { "queryuser", RPC_RTYPE_NTSTATUS, cmd_samr_query_user, NULL, PI_SAMR, NULL, "Query user info", "" },
2398 { "querygroup", RPC_RTYPE_NTSTATUS, cmd_samr_query_group, NULL, PI_SAMR, NULL, "Query group info", "" },
2399 { "queryusergroups", RPC_RTYPE_NTSTATUS, cmd_samr_query_usergroups, NULL, PI_SAMR, NULL, "Query user groups", "" },
2400 { "queryuseraliases", RPC_RTYPE_NTSTATUS, cmd_samr_query_useraliases, NULL, PI_SAMR, NULL, "Query user aliases", "" },
2401 { "querygroupmem", RPC_RTYPE_NTSTATUS, cmd_samr_query_groupmem, NULL, PI_SAMR, NULL, "Query group membership", "" },
2402 { "queryaliasmem", RPC_RTYPE_NTSTATUS, cmd_samr_query_aliasmem, NULL, PI_SAMR, NULL, "Query alias membership", "" },
2403 { "deletealias", RPC_RTYPE_NTSTATUS, cmd_samr_delete_alias, NULL, PI_SAMR, NULL, "Delete an alias", "" },
2404 { "querydispinfo", RPC_RTYPE_NTSTATUS, cmd_samr_query_dispinfo, NULL, PI_SAMR, NULL, "Query display info", "" },
2405 { "querydispinfo2", RPC_RTYPE_NTSTATUS, cmd_samr_query_dispinfo2, NULL, PI_SAMR, NULL, "Query display info 2", "" },
2406 { "querydispinfo3", RPC_RTYPE_NTSTATUS, cmd_samr_query_dispinfo3, NULL, PI_SAMR, NULL, "Query display info 3", "" },
2407 { "getdispenumindex", RPC_RTYPE_NTSTATUS, cmd_samr_get_dispenum_index, NULL, PI_SAMR, NULL, "Query display info index", "" },
2408 { "getdispenumindex2", RPC_RTYPE_NTSTATUS, cmd_samr_get_dispenum_index2, NULL, PI_SAMR, NULL, "Query display info index", "" },
2409 { "querydominfo", RPC_RTYPE_NTSTATUS, cmd_samr_query_dominfo, NULL, PI_SAMR, NULL, "Query domain info", "" },
2410 { "enumdomusers", RPC_RTYPE_NTSTATUS, cmd_samr_enum_dom_users, NULL, PI_SAMR, NULL, "Enumerate domain users", "" },
2411 { "enumdomgroups", RPC_RTYPE_NTSTATUS, cmd_samr_enum_dom_groups, NULL, PI_SAMR, NULL, "Enumerate domain groups", "" },
2412 { "enumalsgroups", RPC_RTYPE_NTSTATUS, cmd_samr_enum_als_groups, NULL, PI_SAMR, NULL, "Enumerate alias groups", "" },
2414 { "createdomuser", RPC_RTYPE_NTSTATUS, cmd_samr_create_dom_user, NULL, PI_SAMR, NULL, "Create domain user", "" },
2415 { "createdomgroup", RPC_RTYPE_NTSTATUS, cmd_samr_create_dom_group, NULL, PI_SAMR, NULL, "Create domain group", "" },
2416 { "createdomalias", RPC_RTYPE_NTSTATUS, cmd_samr_create_dom_alias, NULL, PI_SAMR, NULL, "Create domain alias", "" },
2417 { "samlookupnames", RPC_RTYPE_NTSTATUS, cmd_samr_lookup_names, NULL, PI_SAMR, NULL, "Look up names", "" },
2418 { "samlookuprids", RPC_RTYPE_NTSTATUS, cmd_samr_lookup_rids, NULL, PI_SAMR, NULL, "Look up names", "" },
2419 { "deletedomgroup", RPC_RTYPE_NTSTATUS, cmd_samr_delete_dom_group, NULL, PI_SAMR, NULL, "Delete domain group", "" },
2420 { "deletedomuser", RPC_RTYPE_NTSTATUS, cmd_samr_delete_dom_user, NULL, PI_SAMR, NULL, "Delete domain user", "" },
2421 { "samquerysecobj", RPC_RTYPE_NTSTATUS, cmd_samr_query_sec_obj, NULL, PI_SAMR, NULL, "Query SAMR security object", "" },
2422 { "getdompwinfo", RPC_RTYPE_NTSTATUS, cmd_samr_get_dom_pwinfo, NULL, PI_SAMR, NULL, "Retrieve domain password info", "" },
2423 { "getusrdompwinfo", RPC_RTYPE_NTSTATUS, cmd_samr_get_usrdom_pwinfo, NULL, PI_SAMR, NULL, "Retrieve user domain password info", "" },
2425 { "lookupdomain", RPC_RTYPE_NTSTATUS, cmd_samr_lookup_domain, NULL, PI_SAMR, NULL, "Lookup Domain Name", "" },
2426 { "chgpasswd2", RPC_RTYPE_NTSTATUS, cmd_samr_chgpasswd2, NULL, PI_SAMR, NULL, "Change user password", "" },
2427 { "chgpasswd3", RPC_RTYPE_NTSTATUS, cmd_samr_chgpasswd3, NULL, PI_SAMR, NULL, "Change user password", "" },