mirror of
https://github.com/samba-team/samba.git
synced 2024-12-25 23:21:54 +03:00
1c788bc365
Guenther
(This used to be commit d1c669920e
)
2518 lines
64 KiB
C
2518 lines
64 KiB
C
/*
|
|
Unix SMB/CIFS implementation.
|
|
RPC pipe client
|
|
|
|
Copyright (C) Andrew Tridgell 1992-2000,
|
|
Copyright (C) Luke Kenneth Casson Leighton 1996-2000,
|
|
Copyright (C) Elrond 2000,
|
|
Copyright (C) Tim Potter 2000
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include "includes.h"
|
|
#include "rpcclient.h"
|
|
|
|
extern DOM_SID domain_sid;
|
|
|
|
static void init_lsa_String(struct lsa_String *name, const char *s)
|
|
{
|
|
name->string = s;
|
|
}
|
|
|
|
/****************************************************************************
|
|
display sam_user_info_7 structure
|
|
****************************************************************************/
|
|
static void display_sam_user_info_7(SAM_USER_INFO_7 *usr)
|
|
{
|
|
fstring temp;
|
|
|
|
unistr2_to_ascii(temp, &usr->uni_name, sizeof(temp));
|
|
printf("\tUser Name :\t%s\n", temp);
|
|
}
|
|
|
|
/****************************************************************************
|
|
display sam_user_info_9 structure
|
|
****************************************************************************/
|
|
static void display_sam_user_info_9(SAM_USER_INFO_9 *usr)
|
|
{
|
|
printf("\tPrimary group RID :\tox%x\n", usr->rid_group);
|
|
}
|
|
|
|
/****************************************************************************
|
|
display sam_user_info_16 structure
|
|
****************************************************************************/
|
|
static void display_sam_user_info_16(SAM_USER_INFO_16 *usr)
|
|
{
|
|
printf("\tAcct Flags :\tox%x\n", usr->acb_info);
|
|
}
|
|
|
|
/****************************************************************************
|
|
display sam_user_info_21 structure
|
|
****************************************************************************/
|
|
static void display_sam_user_info_21(SAM_USER_INFO_21 *usr)
|
|
{
|
|
fstring temp;
|
|
|
|
unistr2_to_ascii(temp, &usr->uni_user_name, sizeof(temp));
|
|
printf("\tUser Name :\t%s\n", temp);
|
|
|
|
unistr2_to_ascii(temp, &usr->uni_full_name, sizeof(temp));
|
|
printf("\tFull Name :\t%s\n", temp);
|
|
|
|
unistr2_to_ascii(temp, &usr->uni_home_dir, sizeof(temp));
|
|
printf("\tHome Drive :\t%s\n", temp);
|
|
|
|
unistr2_to_ascii(temp, &usr->uni_dir_drive, sizeof(temp));
|
|
printf("\tDir Drive :\t%s\n", temp);
|
|
|
|
unistr2_to_ascii(temp, &usr->uni_profile_path, sizeof(temp));
|
|
printf("\tProfile Path:\t%s\n", temp);
|
|
|
|
unistr2_to_ascii(temp, &usr->uni_logon_script, sizeof(temp));
|
|
printf("\tLogon Script:\t%s\n", temp);
|
|
|
|
unistr2_to_ascii(temp, &usr->uni_acct_desc, sizeof(temp));
|
|
printf("\tDescription :\t%s\n", temp);
|
|
|
|
unistr2_to_ascii(temp, &usr->uni_workstations, sizeof(temp));
|
|
printf("\tWorkstations:\t%s\n", temp);
|
|
|
|
unistr2_to_ascii(temp, &usr->uni_comment, sizeof(temp));
|
|
printf("\tUnknown Str :\t%s\n", temp);
|
|
|
|
unistr2_to_ascii(temp, &usr->uni_munged_dial, sizeof(temp));
|
|
printf("\tRemote Dial :\t%s\n", temp);
|
|
|
|
printf("\tLogon Time :\t%s\n",
|
|
http_timestring(nt_time_to_unix(usr->logon_time)));
|
|
printf("\tLogoff Time :\t%s\n",
|
|
http_timestring(nt_time_to_unix(usr->logoff_time)));
|
|
printf("\tKickoff Time :\t%s\n",
|
|
http_timestring(nt_time_to_unix(usr->kickoff_time)));
|
|
printf("\tPassword last set Time :\t%s\n",
|
|
http_timestring(nt_time_to_unix(usr->pass_last_set_time)));
|
|
printf("\tPassword can change Time :\t%s\n",
|
|
http_timestring(nt_time_to_unix(usr->pass_can_change_time)));
|
|
printf("\tPassword must change Time:\t%s\n",
|
|
http_timestring(nt_time_to_unix(usr->pass_must_change_time)));
|
|
|
|
printf("\tunknown_2[0..31]...\n"); /* user passwords? */
|
|
|
|
printf("\tuser_rid :\t0x%x\n" , usr->user_rid ); /* User ID */
|
|
printf("\tgroup_rid:\t0x%x\n" , usr->group_rid); /* Group ID */
|
|
printf("\tacb_info :\t0x%08x\n", usr->acb_info ); /* Account Control Info */
|
|
|
|
printf("\tfields_present:\t0x%08x\n", usr->fields_present); /* 0x00ff ffff */
|
|
printf("\tlogon_divs:\t%d\n", usr->logon_divs); /* 0x0000 00a8 which is 168 which is num hrs in a week */
|
|
printf("\tbad_password_count:\t0x%08x\n", usr->bad_password_count);
|
|
printf("\tlogon_count:\t0x%08x\n", usr->logon_count);
|
|
|
|
printf("\tpadding1[0..7]...\n");
|
|
|
|
if (usr->ptr_logon_hrs) {
|
|
printf("\tlogon_hrs[0..%d]...\n", usr->logon_hrs.len);
|
|
}
|
|
}
|
|
|
|
|
|
static void display_password_properties(uint32_t password_properties)
|
|
{
|
|
printf("password_properties: 0x%08x\n", password_properties);
|
|
|
|
if (password_properties & DOMAIN_PASSWORD_COMPLEX)
|
|
printf("\tDOMAIN_PASSWORD_COMPLEX\n");
|
|
|
|
if (password_properties & DOMAIN_PASSWORD_NO_ANON_CHANGE)
|
|
printf("\tDOMAIN_PASSWORD_NO_ANON_CHANGE\n");
|
|
|
|
if (password_properties & DOMAIN_PASSWORD_NO_CLEAR_CHANGE)
|
|
printf("\tDOMAIN_PASSWORD_NO_CLEAR_CHANGE\n");
|
|
|
|
if (password_properties & DOMAIN_PASSWORD_LOCKOUT_ADMINS)
|
|
printf("\tDOMAIN_PASSWORD_LOCKOUT_ADMINS\n");
|
|
|
|
if (password_properties & DOMAIN_PASSWORD_STORE_CLEARTEXT)
|
|
printf("\tDOMAIN_PASSWORD_STORE_CLEARTEXT\n");
|
|
|
|
if (password_properties & DOMAIN_REFUSE_PASSWORD_CHANGE)
|
|
printf("\tDOMAIN_REFUSE_PASSWORD_CHANGE\n");
|
|
}
|
|
|
|
static void display_sam_dom_info_1(struct samr_DomInfo1 *info1)
|
|
{
|
|
printf("Minimum password length:\t\t\t%d\n",
|
|
info1->min_password_length);
|
|
printf("Password uniqueness (remember x passwords):\t%d\n",
|
|
info1->password_history_length);
|
|
display_password_properties(info1->password_properties);
|
|
printf("password expire in:\t\t\t\t%s\n",
|
|
display_time(info1->max_password_age));
|
|
printf("Min password age (allow changing in x days):\t%s\n",
|
|
display_time(info1->min_password_age));
|
|
}
|
|
|
|
static void display_sam_dom_info_2(struct samr_DomInfo2 *info2)
|
|
{
|
|
printf("Domain:\t\t%s\n", info2->domain_name.string);
|
|
printf("Server:\t\t%s\n", info2->primary.string);
|
|
printf("Comment:\t%s\n", info2->comment.string);
|
|
|
|
printf("Total Users:\t%d\n", info2->num_users);
|
|
printf("Total Groups:\t%d\n", info2->num_groups);
|
|
printf("Total Aliases:\t%d\n", info2->num_aliases);
|
|
|
|
printf("Sequence No:\t%llu\n", (unsigned long long)info2->sequence_num);
|
|
|
|
printf("Force Logoff:\t%d\n",
|
|
(int)nt_time_to_unix_abs(&info2->force_logoff_time));
|
|
|
|
printf("Unknown 2:\t0x%x\n", info2->unknown2);
|
|
printf("Server Role:\t%s\n", server_role_str(info2->role));
|
|
printf("Unknown 3:\t0x%x\n", info2->unknown3);
|
|
}
|
|
|
|
static void display_sam_dom_info_3(struct samr_DomInfo3 *info3)
|
|
{
|
|
printf("Force Logoff:\t%d\n",
|
|
(int)nt_time_to_unix_abs(&info3->force_logoff_time));
|
|
}
|
|
|
|
static void display_sam_dom_info_4(struct samr_DomInfo4 *info4)
|
|
{
|
|
printf("Comment:\t%s\n", info4->comment.string);
|
|
}
|
|
|
|
static void display_sam_dom_info_5(struct samr_DomInfo5 *info5)
|
|
{
|
|
printf("Domain:\t\t%s\n", info5->domain_name.string);
|
|
}
|
|
|
|
static void display_sam_dom_info_6(struct samr_DomInfo6 *info6)
|
|
{
|
|
printf("Server:\t\t%s\n", info6->primary.string);
|
|
}
|
|
|
|
static void display_sam_dom_info_7(struct samr_DomInfo7 *info7)
|
|
{
|
|
printf("Server Role:\t%s\n", server_role_str(info7->role));
|
|
}
|
|
|
|
static void display_sam_dom_info_8(struct samr_DomInfo8 *info8)
|
|
{
|
|
printf("Sequence No:\t%llu\n", (unsigned long long)info8->sequence_num);
|
|
printf("Domain Create Time:\t%s\n",
|
|
http_timestring(nt_time_to_unix(info8->domain_create_time)));
|
|
}
|
|
|
|
static void display_sam_dom_info_9(struct samr_DomInfo9 *info9)
|
|
{
|
|
printf("unknown:\t%d (0x%08x)\n", info9->unknown, info9->unknown);
|
|
}
|
|
|
|
static void display_sam_dom_info_12(struct samr_DomInfo12 *info12)
|
|
{
|
|
printf("Bad password lockout duration: %s\n",
|
|
display_time(info12->lockout_duration));
|
|
printf("Reset Lockout after: %s\n",
|
|
display_time(info12->lockout_window));
|
|
printf("Lockout after bad attempts: %d\n",
|
|
info12->lockout_threshold);
|
|
}
|
|
|
|
static void display_sam_dom_info_13(struct samr_DomInfo13 *info13)
|
|
{
|
|
printf("Sequence No:\t%llu\n", (unsigned long long)info13->sequence_num);
|
|
printf("Domain Create Time:\t%s\n",
|
|
http_timestring(nt_time_to_unix(info13->domain_create_time)));
|
|
printf("Unknown1:\t%d\n", info13->unknown1);
|
|
printf("Unknown2:\t%d\n", info13->unknown2);
|
|
|
|
}
|
|
|
|
static void display_sam_info_1(SAM_ENTRY1 *e1, SAM_STR1 *s1)
|
|
{
|
|
fstring tmp;
|
|
|
|
printf("index: 0x%x ", e1->user_idx);
|
|
printf("RID: 0x%x ", e1->rid_user);
|
|
printf("acb: 0x%x ", e1->acb_info);
|
|
|
|
unistr2_to_ascii(tmp, &s1->uni_acct_name, sizeof(tmp));
|
|
printf("Account: %s\t", tmp);
|
|
|
|
unistr2_to_ascii(tmp, &s1->uni_full_name, sizeof(tmp));
|
|
printf("Name: %s\t", tmp);
|
|
|
|
unistr2_to_ascii(tmp, &s1->uni_acct_desc, sizeof(tmp));
|
|
printf("Desc: %s\n", tmp);
|
|
}
|
|
|
|
static void display_sam_info_2(SAM_ENTRY2 *e2, SAM_STR2 *s2)
|
|
{
|
|
fstring tmp;
|
|
|
|
printf("index: 0x%x ", e2->user_idx);
|
|
printf("RID: 0x%x ", e2->rid_user);
|
|
printf("acb: 0x%x ", e2->acb_info);
|
|
|
|
unistr2_to_ascii(tmp, &s2->uni_srv_name, sizeof(tmp));
|
|
printf("Account: %s\t", tmp);
|
|
|
|
unistr2_to_ascii(tmp, &s2->uni_srv_desc, sizeof(tmp));
|
|
printf("Name: %s\n", tmp);
|
|
|
|
}
|
|
|
|
static void display_sam_info_3(SAM_ENTRY3 *e3, SAM_STR3 *s3)
|
|
{
|
|
fstring tmp;
|
|
|
|
printf("index: 0x%x ", e3->grp_idx);
|
|
printf("RID: 0x%x ", e3->rid_grp);
|
|
printf("attr: 0x%x ", e3->attr);
|
|
|
|
unistr2_to_ascii(tmp, &s3->uni_grp_name, sizeof(tmp));
|
|
printf("Account: %s\t", tmp);
|
|
|
|
unistr2_to_ascii(tmp, &s3->uni_grp_desc, sizeof(tmp));
|
|
printf("Name: %s\n", tmp);
|
|
|
|
}
|
|
|
|
static void display_sam_info_4(SAM_ENTRY4 *e4, SAM_STR4 *s4)
|
|
{
|
|
int i;
|
|
|
|
printf("index: %d ", e4->user_idx);
|
|
|
|
printf("Account: ");
|
|
for (i=0; i<s4->acct_name.str_str_len; i++)
|
|
printf("%c", s4->acct_name.buffer[i]);
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
static void display_sam_info_5(SAM_ENTRY5 *e5, SAM_STR5 *s5)
|
|
{
|
|
int i;
|
|
|
|
printf("index: 0x%x ", e5->grp_idx);
|
|
|
|
printf("Account: ");
|
|
for (i=0; i<s5->grp_name.str_str_len; i++)
|
|
printf("%c", s5->grp_name.buffer[i]);
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
/****************************************************************************
|
|
Try samr_connect4 first, then samr_connect2 if it fails
|
|
****************************************************************************/
|
|
static NTSTATUS try_samr_connects(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
|
|
uint32 access_mask, POLICY_HND *connect_pol)
|
|
{
|
|
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
|
|
|
|
result = rpccli_samr_Connect4(cli, mem_ctx,
|
|
cli->cli->desthost,
|
|
SAMR_CONNECT_W2K,
|
|
access_mask,
|
|
connect_pol);
|
|
if (!NT_STATUS_IS_OK(result)) {
|
|
result = rpccli_samr_Connect2(cli, mem_ctx,
|
|
cli->cli->desthost,
|
|
access_mask,
|
|
connect_pol);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**********************************************************************
|
|
* Query user information
|
|
*/
|
|
static NTSTATUS cmd_samr_query_user(struct rpc_pipe_client *cli,
|
|
TALLOC_CTX *mem_ctx,
|
|
int argc, const char **argv)
|
|
{
|
|
POLICY_HND connect_pol, domain_pol, user_pol;
|
|
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
|
|
uint32 info_level = 21;
|
|
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
|
|
SAM_USERINFO_CTR *user_ctr;
|
|
fstring server;
|
|
uint32 user_rid = 0;
|
|
|
|
if ((argc < 2) || (argc > 4)) {
|
|
printf("Usage: %s rid [info level] [access mask] \n", argv[0]);
|
|
return NT_STATUS_OK;
|
|
}
|
|
|
|
sscanf(argv[1], "%i", &user_rid);
|
|
|
|
if (argc > 2)
|
|
sscanf(argv[2], "%i", &info_level);
|
|
|
|
if (argc > 3)
|
|
sscanf(argv[3], "%x", &access_mask);
|
|
|
|
|
|
slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
|
|
strupper_m(server);
|
|
|
|
result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
|
|
&connect_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
result = rpccli_samr_OpenDomain(cli, mem_ctx,
|
|
&connect_pol,
|
|
MAXIMUM_ALLOWED_ACCESS,
|
|
&domain_sid,
|
|
&domain_pol);
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
result = rpccli_samr_OpenUser(cli, mem_ctx,
|
|
&domain_pol,
|
|
access_mask,
|
|
user_rid,
|
|
&user_pol);
|
|
|
|
if (NT_STATUS_EQUAL(result, NT_STATUS_NO_SUCH_USER) &&
|
|
(user_rid == 0)) {
|
|
|
|
/* Probably this was a user name, try lookupnames */
|
|
uint32 num_rids;
|
|
uint32 *rids, *types;
|
|
|
|
result = rpccli_samr_lookup_names(cli, mem_ctx, &domain_pol,
|
|
1000, 1, &argv[1],
|
|
&num_rids, &rids,
|
|
&types);
|
|
|
|
if (NT_STATUS_IS_OK(result)) {
|
|
result = rpccli_samr_OpenUser(cli, mem_ctx,
|
|
&domain_pol,
|
|
access_mask,
|
|
rids[0],
|
|
&user_pol);
|
|
}
|
|
}
|
|
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
ZERO_STRUCT(user_ctr);
|
|
|
|
result = rpccli_samr_query_userinfo(cli, mem_ctx, &user_pol,
|
|
info_level, &user_ctr);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
switch (user_ctr->switch_value) {
|
|
case 7:
|
|
display_sam_user_info_7(user_ctr->info.id7);
|
|
break;
|
|
case 9:
|
|
display_sam_user_info_9(user_ctr->info.id9);
|
|
break;
|
|
case 16:
|
|
display_sam_user_info_16(user_ctr->info.id16);
|
|
break;
|
|
case 21:
|
|
display_sam_user_info_21(user_ctr->info.id21);
|
|
break;
|
|
default:
|
|
printf("Unsupported infolevel: %d\n", info_level);
|
|
break;
|
|
}
|
|
|
|
rpccli_samr_Close(cli, mem_ctx, &user_pol);
|
|
rpccli_samr_Close(cli, mem_ctx, &domain_pol);
|
|
rpccli_samr_Close(cli, mem_ctx, &connect_pol);
|
|
|
|
done:
|
|
return result;
|
|
}
|
|
|
|
/****************************************************************************
|
|
display group info
|
|
****************************************************************************/
|
|
static void display_group_info1(struct samr_GroupInfoAll *info1)
|
|
{
|
|
printf("\tGroup Name:\t%s\n", info1->name.string);
|
|
printf("\tDescription:\t%s\n", info1->description.string);
|
|
printf("\tGroup Attribute:%d\n", info1->attributes);
|
|
printf("\tNum Members:%d\n", info1->num_members);
|
|
}
|
|
|
|
/****************************************************************************
|
|
display group info
|
|
****************************************************************************/
|
|
static void display_group_info2(struct lsa_String *info2)
|
|
{
|
|
printf("\tGroup Description:%s\n", info2->string);
|
|
}
|
|
|
|
|
|
/****************************************************************************
|
|
display group info
|
|
****************************************************************************/
|
|
static void display_group_info3(struct samr_GroupInfoAttributes *info3)
|
|
{
|
|
printf("\tGroup Attribute:%d\n", info3->attributes);
|
|
}
|
|
|
|
|
|
/****************************************************************************
|
|
display group info
|
|
****************************************************************************/
|
|
static void display_group_info4(struct lsa_String *info4)
|
|
{
|
|
printf("\tGroup Description:%s\n", info4->string);
|
|
}
|
|
|
|
/****************************************************************************
|
|
display group info
|
|
****************************************************************************/
|
|
static void display_group_info5(struct samr_GroupInfoAll *info5)
|
|
{
|
|
printf("\tGroup Name:\t%s\n", info5->name.string);
|
|
printf("\tDescription:\t%s\n", info5->description.string);
|
|
printf("\tGroup Attribute:%d\n", info5->attributes);
|
|
printf("\tNum Members:%d\n", info5->num_members);
|
|
}
|
|
|
|
/****************************************************************************
|
|
display sam sync structure
|
|
****************************************************************************/
|
|
static void display_group_info(union samr_GroupInfo *info,
|
|
enum samr_GroupInfoEnum level)
|
|
{
|
|
switch (level) {
|
|
case 1:
|
|
display_group_info1(&info->all);
|
|
break;
|
|
case 2:
|
|
display_group_info2(&info->name);
|
|
break;
|
|
case 3:
|
|
display_group_info3(&info->attributes);
|
|
break;
|
|
case 4:
|
|
display_group_info4(&info->description);
|
|
break;
|
|
case 5:
|
|
display_group_info5(&info->all2);
|
|
break;
|
|
}
|
|
}
|
|
|
|
/***********************************************************************
|
|
* Query group information
|
|
*/
|
|
static NTSTATUS cmd_samr_query_group(struct rpc_pipe_client *cli,
|
|
TALLOC_CTX *mem_ctx,
|
|
int argc, const char **argv)
|
|
{
|
|
POLICY_HND connect_pol, domain_pol, group_pol;
|
|
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
|
|
enum samr_GroupInfoEnum info_level = GROUPINFOALL;
|
|
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
|
|
union samr_GroupInfo *group_info = NULL;
|
|
fstring server;
|
|
uint32 group_rid;
|
|
|
|
if ((argc < 2) || (argc > 4)) {
|
|
printf("Usage: %s rid [info level] [access mask]\n", argv[0]);
|
|
return NT_STATUS_OK;
|
|
}
|
|
|
|
sscanf(argv[1], "%i", &group_rid);
|
|
|
|
if (argc > 2)
|
|
info_level = atoi(argv[2]);
|
|
|
|
if (argc > 3)
|
|
sscanf(argv[3], "%x", &access_mask);
|
|
|
|
slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
|
|
strupper_m(server);
|
|
|
|
result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
|
|
&connect_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
result = rpccli_samr_OpenDomain(cli, mem_ctx,
|
|
&connect_pol,
|
|
MAXIMUM_ALLOWED_ACCESS,
|
|
&domain_sid,
|
|
&domain_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
result = rpccli_samr_OpenGroup(cli, mem_ctx,
|
|
&domain_pol,
|
|
access_mask,
|
|
group_rid,
|
|
&group_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
result = rpccli_samr_QueryGroupInfo(cli, mem_ctx,
|
|
&group_pol,
|
|
info_level,
|
|
&group_info);
|
|
if (!NT_STATUS_IS_OK(result)) {
|
|
goto done;
|
|
}
|
|
|
|
display_group_info(group_info, info_level);
|
|
|
|
rpccli_samr_Close(cli, mem_ctx, &group_pol);
|
|
rpccli_samr_Close(cli, mem_ctx, &domain_pol);
|
|
rpccli_samr_Close(cli, mem_ctx, &connect_pol);
|
|
done:
|
|
return result;
|
|
}
|
|
|
|
/* Query groups a user is a member of */
|
|
|
|
static NTSTATUS cmd_samr_query_usergroups(struct rpc_pipe_client *cli,
|
|
TALLOC_CTX *mem_ctx,
|
|
int argc, const char **argv)
|
|
{
|
|
POLICY_HND connect_pol,
|
|
domain_pol,
|
|
user_pol;
|
|
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
|
|
uint32 user_rid;
|
|
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
|
|
int i;
|
|
fstring server;
|
|
struct samr_RidWithAttributeArray *rid_array = NULL;
|
|
|
|
if ((argc < 2) || (argc > 3)) {
|
|
printf("Usage: %s rid [access mask]\n", argv[0]);
|
|
return NT_STATUS_OK;
|
|
}
|
|
|
|
sscanf(argv[1], "%i", &user_rid);
|
|
|
|
if (argc > 2)
|
|
sscanf(argv[2], "%x", &access_mask);
|
|
|
|
slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
|
|
strupper_m(server);
|
|
|
|
result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
|
|
&connect_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
result = rpccli_samr_OpenDomain(cli, mem_ctx,
|
|
&connect_pol,
|
|
MAXIMUM_ALLOWED_ACCESS,
|
|
&domain_sid, &domain_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
result = rpccli_samr_OpenUser(cli, mem_ctx,
|
|
&domain_pol,
|
|
access_mask,
|
|
user_rid,
|
|
&user_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
result = rpccli_samr_GetGroupsForUser(cli, mem_ctx,
|
|
&user_pol,
|
|
&rid_array);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
for (i = 0; i < rid_array->count; i++) {
|
|
printf("\tgroup rid:[0x%x] attr:[0x%x]\n",
|
|
rid_array->rids[i].rid,
|
|
rid_array->rids[i].attributes);
|
|
}
|
|
|
|
rpccli_samr_Close(cli, mem_ctx, &user_pol);
|
|
rpccli_samr_Close(cli, mem_ctx, &domain_pol);
|
|
rpccli_samr_Close(cli, mem_ctx, &connect_pol);
|
|
done:
|
|
return result;
|
|
}
|
|
|
|
/* Query aliases a user is a member of */
|
|
|
|
static NTSTATUS cmd_samr_query_useraliases(struct rpc_pipe_client *cli,
|
|
TALLOC_CTX *mem_ctx,
|
|
int argc, const char **argv)
|
|
{
|
|
POLICY_HND connect_pol, domain_pol;
|
|
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
|
|
DOM_SID *sids;
|
|
size_t num_sids;
|
|
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
|
|
int i;
|
|
fstring server;
|
|
struct lsa_SidArray sid_array;
|
|
struct samr_Ids alias_rids;
|
|
|
|
if (argc < 3) {
|
|
printf("Usage: %s builtin|domain sid1 sid2 ...\n", argv[0]);
|
|
return NT_STATUS_INVALID_PARAMETER;
|
|
}
|
|
|
|
sids = NULL;
|
|
num_sids = 0;
|
|
|
|
for (i=2; i<argc; i++) {
|
|
DOM_SID tmp_sid;
|
|
if (!string_to_sid(&tmp_sid, argv[i])) {
|
|
printf("%s is not a legal SID\n", argv[i]);
|
|
return NT_STATUS_INVALID_PARAMETER;
|
|
}
|
|
result = add_sid_to_array(mem_ctx, &tmp_sid, &sids, &num_sids);
|
|
if (!NT_STATUS_IS_OK(result)) {
|
|
return result;
|
|
}
|
|
}
|
|
|
|
if (num_sids) {
|
|
sid_array.sids = TALLOC_ZERO_ARRAY(mem_ctx, struct lsa_SidPtr, num_sids);
|
|
if (sid_array.sids == NULL)
|
|
return NT_STATUS_NO_MEMORY;
|
|
} else {
|
|
sid_array.sids = NULL;
|
|
}
|
|
|
|
for (i=0; i<num_sids; i++) {
|
|
sid_array.sids[i].sid = sid_dup_talloc(mem_ctx, &sids[i]);
|
|
if (!sid_array.sids[i].sid) {
|
|
return NT_STATUS_NO_MEMORY;
|
|
}
|
|
}
|
|
|
|
sid_array.num_sids = num_sids;
|
|
|
|
slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
|
|
strupper_m(server);
|
|
|
|
result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
|
|
&connect_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
if (StrCaseCmp(argv[1], "domain")==0)
|
|
result = rpccli_samr_OpenDomain(cli, mem_ctx,
|
|
&connect_pol,
|
|
access_mask,
|
|
&domain_sid, &domain_pol);
|
|
else if (StrCaseCmp(argv[1], "builtin")==0)
|
|
result = rpccli_samr_OpenDomain(cli, mem_ctx,
|
|
&connect_pol,
|
|
access_mask,
|
|
CONST_DISCARD(struct dom_sid2 *, &global_sid_Builtin),
|
|
&domain_pol);
|
|
else {
|
|
printf("Usage: %s builtin|domain sid1 sid2 ...\n", argv[0]);
|
|
return NT_STATUS_INVALID_PARAMETER;
|
|
}
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
result = rpccli_samr_GetAliasMembership(cli, mem_ctx,
|
|
&domain_pol,
|
|
&sid_array,
|
|
&alias_rids);
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
for (i = 0; i < alias_rids.count; i++) {
|
|
printf("\tgroup rid:[0x%x]\n", alias_rids.ids[i]);
|
|
}
|
|
|
|
rpccli_samr_Close(cli, mem_ctx, &domain_pol);
|
|
rpccli_samr_Close(cli, mem_ctx, &connect_pol);
|
|
done:
|
|
return result;
|
|
}
|
|
|
|
/* Query members of a group */
|
|
|
|
static NTSTATUS cmd_samr_query_groupmem(struct rpc_pipe_client *cli,
|
|
TALLOC_CTX *mem_ctx,
|
|
int argc, const char **argv)
|
|
{
|
|
POLICY_HND connect_pol, domain_pol, group_pol;
|
|
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
|
|
uint32 group_rid;
|
|
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
|
|
int i;
|
|
fstring server;
|
|
unsigned int old_timeout;
|
|
struct samr_RidTypeArray *rids = NULL;
|
|
|
|
if ((argc < 2) || (argc > 3)) {
|
|
printf("Usage: %s rid [access mask]\n", argv[0]);
|
|
return NT_STATUS_OK;
|
|
}
|
|
|
|
sscanf(argv[1], "%i", &group_rid);
|
|
|
|
if (argc > 2)
|
|
sscanf(argv[2], "%x", &access_mask);
|
|
|
|
slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
|
|
strupper_m(server);
|
|
|
|
result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
|
|
&connect_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
result = rpccli_samr_OpenDomain(cli, mem_ctx,
|
|
&connect_pol,
|
|
MAXIMUM_ALLOWED_ACCESS,
|
|
&domain_sid,
|
|
&domain_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
result = rpccli_samr_OpenGroup(cli, mem_ctx,
|
|
&domain_pol,
|
|
access_mask,
|
|
group_rid,
|
|
&group_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
/* Make sure to wait for our DC's reply */
|
|
old_timeout = cli_set_timeout(cli->cli, MAX(cli->cli->timeout,30000)); /* 30 seconds. */
|
|
|
|
result = rpccli_samr_QueryGroupMember(cli, mem_ctx,
|
|
&group_pol,
|
|
&rids);
|
|
|
|
cli_set_timeout(cli->cli, old_timeout);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
for (i = 0; i < rids->count; i++) {
|
|
printf("\trid:[0x%x] attr:[0x%x]\n", rids->rids[i],
|
|
rids->types[i]);
|
|
}
|
|
|
|
rpccli_samr_Close(cli, mem_ctx, &group_pol);
|
|
rpccli_samr_Close(cli, mem_ctx, &domain_pol);
|
|
rpccli_samr_Close(cli, mem_ctx, &connect_pol);
|
|
done:
|
|
return result;
|
|
}
|
|
|
|
/* Enumerate domain users */
|
|
|
|
static NTSTATUS cmd_samr_enum_dom_users(struct rpc_pipe_client *cli,
|
|
TALLOC_CTX *mem_ctx,
|
|
int argc, const char **argv)
|
|
{
|
|
POLICY_HND connect_pol, domain_pol;
|
|
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
|
|
uint32 start_idx, size, num_dom_users, i;
|
|
char **dom_users;
|
|
uint32 *dom_rids;
|
|
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
|
|
uint32 acb_mask = ACB_NORMAL;
|
|
bool got_connect_pol = False, got_domain_pol = False;
|
|
|
|
if ((argc < 1) || (argc > 3)) {
|
|
printf("Usage: %s [access_mask] [acb_mask]\n", argv[0]);
|
|
return NT_STATUS_OK;
|
|
}
|
|
|
|
if (argc > 1)
|
|
sscanf(argv[1], "%x", &access_mask);
|
|
|
|
if (argc > 2)
|
|
sscanf(argv[2], "%x", &acb_mask);
|
|
|
|
/* Get sam policy handle */
|
|
|
|
result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
|
|
&connect_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
got_connect_pol = True;
|
|
|
|
/* Get domain policy handle */
|
|
|
|
result = rpccli_samr_OpenDomain(cli, mem_ctx,
|
|
&connect_pol,
|
|
access_mask,
|
|
&domain_sid,
|
|
&domain_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
got_domain_pol = True;
|
|
|
|
/* Enumerate domain users */
|
|
|
|
start_idx = 0;
|
|
size = 0xffff;
|
|
|
|
do {
|
|
result = rpccli_samr_enum_dom_users(
|
|
cli, mem_ctx, &domain_pol, &start_idx, acb_mask,
|
|
size, &dom_users, &dom_rids, &num_dom_users);
|
|
|
|
if (NT_STATUS_IS_OK(result) ||
|
|
NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES)) {
|
|
|
|
for (i = 0; i < num_dom_users; i++)
|
|
printf("user:[%s] rid:[0x%x]\n",
|
|
dom_users[i], dom_rids[i]);
|
|
}
|
|
|
|
} while (NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES));
|
|
|
|
done:
|
|
if (got_domain_pol)
|
|
rpccli_samr_Close(cli, mem_ctx, &domain_pol);
|
|
|
|
if (got_connect_pol)
|
|
rpccli_samr_Close(cli, mem_ctx, &connect_pol);
|
|
|
|
return result;
|
|
}
|
|
|
|
/* Enumerate domain groups */
|
|
|
|
static NTSTATUS cmd_samr_enum_dom_groups(struct rpc_pipe_client *cli,
|
|
TALLOC_CTX *mem_ctx,
|
|
int argc, const char **argv)
|
|
{
|
|
POLICY_HND connect_pol, domain_pol;
|
|
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
|
|
uint32 start_idx, size, num_dom_groups, i;
|
|
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
|
|
struct acct_info *dom_groups;
|
|
bool got_connect_pol = False, got_domain_pol = False;
|
|
|
|
if ((argc < 1) || (argc > 2)) {
|
|
printf("Usage: %s [access_mask]\n", argv[0]);
|
|
return NT_STATUS_OK;
|
|
}
|
|
|
|
if (argc > 1)
|
|
sscanf(argv[1], "%x", &access_mask);
|
|
|
|
/* Get sam policy handle */
|
|
|
|
result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
|
|
&connect_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
got_connect_pol = True;
|
|
|
|
/* Get domain policy handle */
|
|
|
|
result = rpccli_samr_OpenDomain(cli, mem_ctx,
|
|
&connect_pol,
|
|
access_mask,
|
|
&domain_sid,
|
|
&domain_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
got_domain_pol = True;
|
|
|
|
/* Enumerate domain groups */
|
|
|
|
start_idx = 0;
|
|
size = 0xffff;
|
|
|
|
do {
|
|
result = rpccli_samr_enum_dom_groups(
|
|
cli, mem_ctx, &domain_pol, &start_idx, size,
|
|
&dom_groups, &num_dom_groups);
|
|
|
|
if (NT_STATUS_IS_OK(result) ||
|
|
NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES)) {
|
|
|
|
for (i = 0; i < num_dom_groups; i++)
|
|
printf("group:[%s] rid:[0x%x]\n",
|
|
dom_groups[i].acct_name,
|
|
dom_groups[i].rid);
|
|
}
|
|
|
|
} while (NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES));
|
|
|
|
done:
|
|
if (got_domain_pol)
|
|
rpccli_samr_Close(cli, mem_ctx, &domain_pol);
|
|
|
|
if (got_connect_pol)
|
|
rpccli_samr_Close(cli, mem_ctx, &connect_pol);
|
|
|
|
return result;
|
|
}
|
|
|
|
/* Enumerate alias groups */
|
|
|
|
static NTSTATUS cmd_samr_enum_als_groups(struct rpc_pipe_client *cli,
|
|
TALLOC_CTX *mem_ctx,
|
|
int argc, const char **argv)
|
|
{
|
|
POLICY_HND connect_pol, domain_pol;
|
|
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
|
|
uint32 start_idx, size, num_als_groups, i;
|
|
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
|
|
struct acct_info *als_groups;
|
|
bool got_connect_pol = False, got_domain_pol = False;
|
|
|
|
if ((argc < 2) || (argc > 3)) {
|
|
printf("Usage: %s builtin|domain [access mask]\n", argv[0]);
|
|
return NT_STATUS_OK;
|
|
}
|
|
|
|
if (argc > 2)
|
|
sscanf(argv[2], "%x", &access_mask);
|
|
|
|
/* Get sam policy handle */
|
|
|
|
result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
|
|
&connect_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
got_connect_pol = True;
|
|
|
|
/* Get domain policy handle */
|
|
|
|
if (StrCaseCmp(argv[1], "domain")==0)
|
|
result = rpccli_samr_OpenDomain(cli, mem_ctx,
|
|
&connect_pol,
|
|
access_mask,
|
|
&domain_sid,
|
|
&domain_pol);
|
|
else if (StrCaseCmp(argv[1], "builtin")==0)
|
|
result = rpccli_samr_OpenDomain(cli, mem_ctx,
|
|
&connect_pol,
|
|
access_mask,
|
|
CONST_DISCARD(struct dom_sid2 *, &global_sid_Builtin),
|
|
&domain_pol);
|
|
else
|
|
return NT_STATUS_OK;
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
got_domain_pol = True;
|
|
|
|
/* Enumerate alias groups */
|
|
|
|
start_idx = 0;
|
|
size = 0xffff; /* Number of groups to retrieve */
|
|
|
|
do {
|
|
result = rpccli_samr_enum_als_groups(
|
|
cli, mem_ctx, &domain_pol, &start_idx, size,
|
|
&als_groups, &num_als_groups);
|
|
|
|
if (NT_STATUS_IS_OK(result) ||
|
|
NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES)) {
|
|
|
|
for (i = 0; i < num_als_groups; i++)
|
|
printf("group:[%s] rid:[0x%x]\n",
|
|
als_groups[i].acct_name,
|
|
als_groups[i].rid);
|
|
}
|
|
} while (NT_STATUS_V(result) == NT_STATUS_V(STATUS_MORE_ENTRIES));
|
|
|
|
done:
|
|
if (got_domain_pol)
|
|
rpccli_samr_Close(cli, mem_ctx, &domain_pol);
|
|
|
|
if (got_connect_pol)
|
|
rpccli_samr_Close(cli, mem_ctx, &connect_pol);
|
|
|
|
return result;
|
|
}
|
|
|
|
/* Query alias membership */
|
|
|
|
static NTSTATUS cmd_samr_query_aliasmem(struct rpc_pipe_client *cli,
|
|
TALLOC_CTX *mem_ctx,
|
|
int argc, const char **argv)
|
|
{
|
|
POLICY_HND connect_pol, domain_pol, alias_pol;
|
|
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
|
|
uint32 alias_rid, i;
|
|
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
|
|
struct lsa_SidArray sid_array;
|
|
|
|
if ((argc < 3) || (argc > 4)) {
|
|
printf("Usage: %s builtin|domain rid [access mask]\n", argv[0]);
|
|
return NT_STATUS_OK;
|
|
}
|
|
|
|
sscanf(argv[2], "%i", &alias_rid);
|
|
|
|
if (argc > 3)
|
|
sscanf(argv[3], "%x", &access_mask);
|
|
|
|
/* Open SAMR handle */
|
|
|
|
result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
|
|
&connect_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
/* Open handle on domain */
|
|
|
|
if (StrCaseCmp(argv[1], "domain")==0)
|
|
result = rpccli_samr_OpenDomain(cli, mem_ctx,
|
|
&connect_pol,
|
|
MAXIMUM_ALLOWED_ACCESS,
|
|
&domain_sid,
|
|
&domain_pol);
|
|
else if (StrCaseCmp(argv[1], "builtin")==0)
|
|
result = rpccli_samr_OpenDomain(cli, mem_ctx,
|
|
&connect_pol,
|
|
MAXIMUM_ALLOWED_ACCESS,
|
|
CONST_DISCARD(struct dom_sid2 *, &global_sid_Builtin),
|
|
&domain_pol);
|
|
else
|
|
return NT_STATUS_OK;
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
/* Open handle on alias */
|
|
|
|
result = rpccli_samr_OpenAlias(cli, mem_ctx,
|
|
&domain_pol,
|
|
access_mask,
|
|
alias_rid,
|
|
&alias_pol);
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
result = rpccli_samr_GetMembersInAlias(cli, mem_ctx,
|
|
&alias_pol,
|
|
&sid_array);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
for (i = 0; i < sid_array.num_sids; i++) {
|
|
fstring sid_str;
|
|
|
|
sid_to_fstring(sid_str, sid_array.sids[i].sid);
|
|
printf("\tsid:[%s]\n", sid_str);
|
|
}
|
|
|
|
rpccli_samr_Close(cli, mem_ctx, &alias_pol);
|
|
rpccli_samr_Close(cli, mem_ctx, &domain_pol);
|
|
rpccli_samr_Close(cli, mem_ctx, &connect_pol);
|
|
done:
|
|
return result;
|
|
}
|
|
|
|
/* Query alias info */
|
|
|
|
static NTSTATUS cmd_samr_query_aliasinfo(struct rpc_pipe_client *cli,
|
|
TALLOC_CTX *mem_ctx,
|
|
int argc, const char **argv)
|
|
{
|
|
POLICY_HND connect_pol, domain_pol, alias_pol;
|
|
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
|
|
uint32_t alias_rid;
|
|
uint32_t access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
|
|
union samr_AliasInfo *info = NULL;
|
|
enum samr_AliasInfoEnum level = ALIASINFOALL;
|
|
|
|
if ((argc < 3) || (argc > 4)) {
|
|
printf("Usage: %s builtin|domain rid [level] [access mask]\n",
|
|
argv[0]);
|
|
return NT_STATUS_OK;
|
|
}
|
|
|
|
sscanf(argv[2], "%i", &alias_rid);
|
|
|
|
if (argc > 3) {
|
|
level = atoi(argv[3]);
|
|
}
|
|
|
|
if (argc > 4) {
|
|
sscanf(argv[4], "%x", &access_mask);
|
|
}
|
|
|
|
/* Open SAMR handle */
|
|
|
|
result = try_samr_connects(cli, mem_ctx,
|
|
SEC_FLAG_MAXIMUM_ALLOWED,
|
|
&connect_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result)) {
|
|
goto done;
|
|
}
|
|
|
|
/* Open handle on domain */
|
|
|
|
if (strequal(argv[1], "domain")) {
|
|
|
|
result = rpccli_samr_OpenDomain(cli, mem_ctx,
|
|
&connect_pol,
|
|
SEC_FLAG_MAXIMUM_ALLOWED,
|
|
&domain_sid,
|
|
&domain_pol);
|
|
|
|
} else if (strequal(argv[1], "builtin")) {
|
|
|
|
result = rpccli_samr_OpenDomain(cli, mem_ctx,
|
|
&connect_pol,
|
|
SEC_FLAG_MAXIMUM_ALLOWED,
|
|
CONST_DISCARD(struct dom_sid2 *, &global_sid_Builtin),
|
|
&domain_pol);
|
|
|
|
} else {
|
|
return NT_STATUS_OK;
|
|
}
|
|
|
|
if (!NT_STATUS_IS_OK(result)) {
|
|
goto done;
|
|
}
|
|
|
|
/* Open handle on alias */
|
|
|
|
result = rpccli_samr_OpenAlias(cli, mem_ctx,
|
|
&domain_pol,
|
|
access_mask,
|
|
alias_rid,
|
|
&alias_pol);
|
|
if (!NT_STATUS_IS_OK(result)) {
|
|
goto done;
|
|
}
|
|
|
|
result = rpccli_samr_QueryAliasInfo(cli, mem_ctx,
|
|
&alias_pol,
|
|
level,
|
|
&info);
|
|
|
|
if (!NT_STATUS_IS_OK(result)) {
|
|
goto done;
|
|
}
|
|
|
|
switch (level) {
|
|
case ALIASINFOALL:
|
|
printf("Name: %s\n", info->all.name.string);
|
|
printf("Description: %s\n", info->all.description.string);
|
|
printf("Num Members: %d\n", info->all.num_members);
|
|
break;
|
|
case ALIASINFONAME:
|
|
printf("Name: %s\n", info->name.string);
|
|
break;
|
|
case ALIASINFODESCRIPTION:
|
|
printf("Description: %s\n", info->description.string);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
rpccli_samr_Close(cli, mem_ctx, &alias_pol);
|
|
rpccli_samr_Close(cli, mem_ctx, &domain_pol);
|
|
rpccli_samr_Close(cli, mem_ctx, &connect_pol);
|
|
done:
|
|
return result;
|
|
}
|
|
|
|
|
|
/* Query delete an alias membership */
|
|
|
|
static NTSTATUS cmd_samr_delete_alias(struct rpc_pipe_client *cli,
|
|
TALLOC_CTX *mem_ctx,
|
|
int argc, const char **argv)
|
|
{
|
|
POLICY_HND connect_pol, domain_pol, alias_pol;
|
|
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
|
|
uint32 alias_rid;
|
|
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
|
|
|
|
if (argc != 3) {
|
|
printf("Usage: %s builtin|domain [rid|name]\n", argv[0]);
|
|
return NT_STATUS_OK;
|
|
}
|
|
|
|
alias_rid = strtoul(argv[2], NULL, 10);
|
|
|
|
/* Open SAMR handle */
|
|
|
|
result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
|
|
&connect_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
/* Open handle on domain */
|
|
|
|
if (StrCaseCmp(argv[1], "domain")==0)
|
|
result = rpccli_samr_OpenDomain(cli, mem_ctx,
|
|
&connect_pol,
|
|
MAXIMUM_ALLOWED_ACCESS,
|
|
&domain_sid,
|
|
&domain_pol);
|
|
else if (StrCaseCmp(argv[1], "builtin")==0)
|
|
result = rpccli_samr_OpenDomain(cli, mem_ctx,
|
|
&connect_pol,
|
|
MAXIMUM_ALLOWED_ACCESS,
|
|
CONST_DISCARD(struct dom_sid2 *, &global_sid_Builtin),
|
|
&domain_pol);
|
|
else
|
|
return NT_STATUS_INVALID_PARAMETER;
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
/* Open handle on alias */
|
|
|
|
result = rpccli_samr_OpenAlias(cli, mem_ctx,
|
|
&domain_pol,
|
|
access_mask,
|
|
alias_rid,
|
|
&alias_pol);
|
|
if (!NT_STATUS_IS_OK(result) && (alias_rid == 0)) {
|
|
/* Probably this was a user name, try lookupnames */
|
|
uint32 num_rids;
|
|
uint32 *rids, *types;
|
|
|
|
result = rpccli_samr_lookup_names(cli, mem_ctx, &domain_pol,
|
|
1000, 1, &argv[2],
|
|
&num_rids, &rids,
|
|
&types);
|
|
|
|
if (NT_STATUS_IS_OK(result)) {
|
|
result = rpccli_samr_OpenAlias(cli, mem_ctx,
|
|
&domain_pol,
|
|
access_mask,
|
|
rids[0],
|
|
&alias_pol);
|
|
}
|
|
}
|
|
|
|
result = rpccli_samr_DeleteDomAlias(cli, mem_ctx,
|
|
&alias_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
rpccli_samr_Close(cli, mem_ctx, &domain_pol);
|
|
rpccli_samr_Close(cli, mem_ctx, &connect_pol);
|
|
done:
|
|
return result;
|
|
}
|
|
|
|
/* Query display info */
|
|
|
|
static NTSTATUS cmd_samr_query_dispinfo(struct rpc_pipe_client *cli,
|
|
TALLOC_CTX *mem_ctx,
|
|
int argc, const char **argv)
|
|
{
|
|
POLICY_HND connect_pol, domain_pol;
|
|
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
|
|
uint32 start_idx=0, max_entries=250, max_size = 0xffff, num_entries, i;
|
|
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
|
|
uint32 info_level = 1;
|
|
SAM_DISPINFO_CTR ctr;
|
|
SAM_DISPINFO_1 info1;
|
|
SAM_DISPINFO_2 info2;
|
|
SAM_DISPINFO_3 info3;
|
|
SAM_DISPINFO_4 info4;
|
|
SAM_DISPINFO_5 info5;
|
|
int loop_count = 0;
|
|
bool got_params = False; /* Use get_query_dispinfo_params() or not? */
|
|
|
|
if (argc > 6) {
|
|
printf("Usage: %s [info level] [start index] [max entries] [max size] [access mask]\n", argv[0]);
|
|
return NT_STATUS_OK;
|
|
}
|
|
|
|
if (argc >= 2)
|
|
sscanf(argv[1], "%i", &info_level);
|
|
|
|
if (argc >= 3)
|
|
sscanf(argv[2], "%i", &start_idx);
|
|
|
|
if (argc >= 4) {
|
|
sscanf(argv[3], "%i", &max_entries);
|
|
got_params = True;
|
|
}
|
|
|
|
if (argc >= 5) {
|
|
sscanf(argv[4], "%i", &max_size);
|
|
got_params = True;
|
|
}
|
|
|
|
if (argc >= 6)
|
|
sscanf(argv[5], "%x", &access_mask);
|
|
|
|
/* Get sam policy handle */
|
|
|
|
result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
|
|
&connect_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
/* Get domain policy handle */
|
|
|
|
result = rpccli_samr_OpenDomain(cli, mem_ctx,
|
|
&connect_pol,
|
|
access_mask,
|
|
&domain_sid,
|
|
&domain_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
/* Query display info */
|
|
|
|
ZERO_STRUCT(ctr);
|
|
ZERO_STRUCT(info1);
|
|
|
|
switch (info_level) {
|
|
case 1:
|
|
ZERO_STRUCT(info1);
|
|
ctr.sam.info1 = &info1;
|
|
break;
|
|
case 2:
|
|
ZERO_STRUCT(info2);
|
|
ctr.sam.info2 = &info2;
|
|
break;
|
|
case 3:
|
|
ZERO_STRUCT(info3);
|
|
ctr.sam.info3 = &info3;
|
|
break;
|
|
case 4:
|
|
ZERO_STRUCT(info4);
|
|
ctr.sam.info4 = &info4;
|
|
break;
|
|
case 5:
|
|
ZERO_STRUCT(info5);
|
|
ctr.sam.info5 = &info5;
|
|
break;
|
|
}
|
|
|
|
|
|
do {
|
|
|
|
if (!got_params)
|
|
get_query_dispinfo_params(
|
|
loop_count, &max_entries, &max_size);
|
|
|
|
result = rpccli_samr_query_dispinfo(cli, mem_ctx, &domain_pol,
|
|
&start_idx, info_level,
|
|
&num_entries, max_entries,
|
|
max_size, &ctr);
|
|
|
|
loop_count++;
|
|
|
|
if (NT_STATUS_IS_ERR(result))
|
|
break;
|
|
|
|
if (num_entries == 0)
|
|
break;
|
|
|
|
for (i = 0; i < num_entries; i++) {
|
|
switch (info_level) {
|
|
case 1:
|
|
display_sam_info_1(&ctr.sam.info1->sam[i], &ctr.sam.info1->str[i]);
|
|
break;
|
|
case 2:
|
|
display_sam_info_2(&ctr.sam.info2->sam[i], &ctr.sam.info2->str[i]);
|
|
break;
|
|
case 3:
|
|
display_sam_info_3(&ctr.sam.info3->sam[i], &ctr.sam.info3->str[i]);
|
|
break;
|
|
case 4:
|
|
display_sam_info_4(&ctr.sam.info4->sam[i], &ctr.sam.info4->str[i]);
|
|
break;
|
|
case 5:
|
|
display_sam_info_5(&ctr.sam.info5->sam[i], &ctr.sam.info5->str[i]);
|
|
break;
|
|
}
|
|
}
|
|
} while ( NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES));
|
|
|
|
rpccli_samr_Close(cli, mem_ctx, &domain_pol);
|
|
rpccli_samr_Close(cli, mem_ctx, &connect_pol);
|
|
done:
|
|
return result;
|
|
}
|
|
|
|
/* Query domain info */
|
|
|
|
static NTSTATUS cmd_samr_query_dominfo(struct rpc_pipe_client *cli,
|
|
TALLOC_CTX *mem_ctx,
|
|
int argc, const char **argv)
|
|
{
|
|
POLICY_HND connect_pol, domain_pol;
|
|
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
|
|
uint32 switch_level = 2;
|
|
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
|
|
union samr_DomainInfo *info = NULL;
|
|
|
|
if (argc > 3) {
|
|
printf("Usage: %s [info level] [access mask]\n", argv[0]);
|
|
return NT_STATUS_OK;
|
|
}
|
|
|
|
if (argc > 1)
|
|
sscanf(argv[1], "%i", &switch_level);
|
|
|
|
if (argc > 2)
|
|
sscanf(argv[2], "%x", &access_mask);
|
|
|
|
/* Get sam policy handle */
|
|
|
|
result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
|
|
&connect_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
/* Get domain policy handle */
|
|
|
|
result = rpccli_samr_OpenDomain(cli, mem_ctx,
|
|
&connect_pol,
|
|
access_mask,
|
|
&domain_sid,
|
|
&domain_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
/* Query domain info */
|
|
|
|
result = rpccli_samr_QueryDomainInfo(cli, mem_ctx,
|
|
&domain_pol,
|
|
switch_level,
|
|
&info);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
/* Display domain info */
|
|
|
|
switch (switch_level) {
|
|
case 1:
|
|
display_sam_dom_info_1(&info->info1);
|
|
break;
|
|
case 2:
|
|
display_sam_dom_info_2(&info->info2);
|
|
break;
|
|
case 3:
|
|
display_sam_dom_info_3(&info->info3);
|
|
break;
|
|
case 4:
|
|
display_sam_dom_info_4(&info->info4);
|
|
break;
|
|
case 5:
|
|
display_sam_dom_info_5(&info->info5);
|
|
break;
|
|
case 6:
|
|
display_sam_dom_info_6(&info->info6);
|
|
break;
|
|
case 7:
|
|
display_sam_dom_info_7(&info->info7);
|
|
break;
|
|
case 8:
|
|
display_sam_dom_info_8(&info->info8);
|
|
break;
|
|
case 9:
|
|
display_sam_dom_info_9(&info->info9);
|
|
break;
|
|
case 12:
|
|
display_sam_dom_info_12(&info->info12);
|
|
break;
|
|
case 13:
|
|
display_sam_dom_info_13(&info->info13);
|
|
break;
|
|
|
|
default:
|
|
printf("cannot display domain info for switch value %d\n",
|
|
switch_level);
|
|
break;
|
|
}
|
|
|
|
done:
|
|
|
|
rpccli_samr_Close(cli, mem_ctx, &domain_pol);
|
|
rpccli_samr_Close(cli, mem_ctx, &connect_pol);
|
|
return result;
|
|
}
|
|
|
|
/* Create domain user */
|
|
|
|
static NTSTATUS cmd_samr_create_dom_user(struct rpc_pipe_client *cli,
|
|
TALLOC_CTX *mem_ctx,
|
|
int argc, const char **argv)
|
|
{
|
|
POLICY_HND connect_pol, domain_pol, user_pol;
|
|
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
|
|
struct lsa_String acct_name;
|
|
uint32 acb_info;
|
|
uint32 acct_flags, user_rid;
|
|
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
|
|
uint32_t access_granted = 0;
|
|
|
|
if ((argc < 2) || (argc > 3)) {
|
|
printf("Usage: %s username [access mask]\n", argv[0]);
|
|
return NT_STATUS_OK;
|
|
}
|
|
|
|
init_lsa_String(&acct_name, argv[1]);
|
|
|
|
if (argc > 2)
|
|
sscanf(argv[2], "%x", &access_mask);
|
|
|
|
/* Get sam policy handle */
|
|
|
|
result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
|
|
&connect_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
/* Get domain policy handle */
|
|
|
|
result = rpccli_samr_OpenDomain(cli, mem_ctx,
|
|
&connect_pol,
|
|
access_mask,
|
|
&domain_sid,
|
|
&domain_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
/* Create domain user */
|
|
|
|
acb_info = ACB_NORMAL;
|
|
acct_flags = SEC_GENERIC_READ | SEC_GENERIC_WRITE | SEC_GENERIC_EXECUTE |
|
|
SEC_STD_WRITE_DAC | SEC_STD_DELETE |
|
|
SAMR_USER_ACCESS_SET_PASSWORD |
|
|
SAMR_USER_ACCESS_GET_ATTRIBUTES |
|
|
SAMR_USER_ACCESS_SET_ATTRIBUTES;
|
|
|
|
result = rpccli_samr_CreateUser2(cli, mem_ctx,
|
|
&domain_pol,
|
|
&acct_name,
|
|
acb_info,
|
|
acct_flags,
|
|
&user_pol,
|
|
&access_granted,
|
|
&user_rid);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
result = rpccli_samr_Close(cli, mem_ctx, &user_pol);
|
|
if (!NT_STATUS_IS_OK(result)) goto done;
|
|
|
|
result = rpccli_samr_Close(cli, mem_ctx, &domain_pol);
|
|
if (!NT_STATUS_IS_OK(result)) goto done;
|
|
|
|
result = rpccli_samr_Close(cli, mem_ctx, &connect_pol);
|
|
if (!NT_STATUS_IS_OK(result)) goto done;
|
|
|
|
done:
|
|
return result;
|
|
}
|
|
|
|
/* Create domain group */
|
|
|
|
static NTSTATUS cmd_samr_create_dom_group(struct rpc_pipe_client *cli,
|
|
TALLOC_CTX *mem_ctx,
|
|
int argc, const char **argv)
|
|
{
|
|
POLICY_HND connect_pol, domain_pol, group_pol;
|
|
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
|
|
struct lsa_String grp_name;
|
|
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
|
|
uint32_t rid = 0;
|
|
|
|
if ((argc < 2) || (argc > 3)) {
|
|
printf("Usage: %s groupname [access mask]\n", argv[0]);
|
|
return NT_STATUS_OK;
|
|
}
|
|
|
|
init_lsa_String(&grp_name, argv[1]);
|
|
|
|
if (argc > 2)
|
|
sscanf(argv[2], "%x", &access_mask);
|
|
|
|
/* Get sam policy handle */
|
|
|
|
result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
|
|
&connect_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
/* Get domain policy handle */
|
|
|
|
result = rpccli_samr_OpenDomain(cli, mem_ctx,
|
|
&connect_pol,
|
|
access_mask,
|
|
&domain_sid,
|
|
&domain_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
/* Create domain user */
|
|
result = rpccli_samr_CreateDomainGroup(cli, mem_ctx,
|
|
&domain_pol,
|
|
&grp_name,
|
|
MAXIMUM_ALLOWED_ACCESS,
|
|
&group_pol,
|
|
&rid);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
result = rpccli_samr_Close(cli, mem_ctx, &group_pol);
|
|
if (!NT_STATUS_IS_OK(result)) goto done;
|
|
|
|
result = rpccli_samr_Close(cli, mem_ctx, &domain_pol);
|
|
if (!NT_STATUS_IS_OK(result)) goto done;
|
|
|
|
result = rpccli_samr_Close(cli, mem_ctx, &connect_pol);
|
|
if (!NT_STATUS_IS_OK(result)) goto done;
|
|
|
|
done:
|
|
return result;
|
|
}
|
|
|
|
/* Create domain alias */
|
|
|
|
static NTSTATUS cmd_samr_create_dom_alias(struct rpc_pipe_client *cli,
|
|
TALLOC_CTX *mem_ctx,
|
|
int argc, const char **argv)
|
|
{
|
|
POLICY_HND connect_pol, domain_pol, alias_pol;
|
|
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
|
|
struct lsa_String alias_name;
|
|
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
|
|
uint32_t rid = 0;
|
|
|
|
if ((argc < 2) || (argc > 3)) {
|
|
printf("Usage: %s aliasname [access mask]\n", argv[0]);
|
|
return NT_STATUS_OK;
|
|
}
|
|
|
|
init_lsa_String(&alias_name, argv[1]);
|
|
|
|
if (argc > 2)
|
|
sscanf(argv[2], "%x", &access_mask);
|
|
|
|
/* Get sam policy handle */
|
|
|
|
result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
|
|
&connect_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
/* Get domain policy handle */
|
|
|
|
result = rpccli_samr_OpenDomain(cli, mem_ctx,
|
|
&connect_pol,
|
|
access_mask,
|
|
&domain_sid,
|
|
&domain_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
/* Create domain user */
|
|
|
|
result = rpccli_samr_CreateDomAlias(cli, mem_ctx,
|
|
&domain_pol,
|
|
&alias_name,
|
|
MAXIMUM_ALLOWED_ACCESS,
|
|
&alias_pol,
|
|
&rid);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
result = rpccli_samr_Close(cli, mem_ctx, &alias_pol);
|
|
if (!NT_STATUS_IS_OK(result)) goto done;
|
|
|
|
result = rpccli_samr_Close(cli, mem_ctx, &domain_pol);
|
|
if (!NT_STATUS_IS_OK(result)) goto done;
|
|
|
|
result = rpccli_samr_Close(cli, mem_ctx, &connect_pol);
|
|
if (!NT_STATUS_IS_OK(result)) goto done;
|
|
|
|
done:
|
|
return result;
|
|
}
|
|
|
|
/* Lookup sam names */
|
|
|
|
static NTSTATUS cmd_samr_lookup_names(struct rpc_pipe_client *cli,
|
|
TALLOC_CTX *mem_ctx,
|
|
int argc, const char **argv)
|
|
{
|
|
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
|
|
POLICY_HND connect_pol, domain_pol;
|
|
uint32 flags = 0x000003e8; /* Unknown */
|
|
uint32 num_rids, num_names, *name_types, *rids;
|
|
const char **names;
|
|
int i;
|
|
|
|
if (argc < 3) {
|
|
printf("Usage: %s domain|builtin name1 [name2 [name3] [...]]\n", argv[0]);
|
|
printf("check on the domain SID: S-1-5-21-x-y-z\n");
|
|
printf("or check on the builtin SID: S-1-5-32\n");
|
|
return NT_STATUS_OK;
|
|
}
|
|
|
|
/* Get sam policy and domain handles */
|
|
|
|
result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
|
|
&connect_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
if (StrCaseCmp(argv[1], "domain")==0)
|
|
result = rpccli_samr_OpenDomain(cli, mem_ctx,
|
|
&connect_pol,
|
|
MAXIMUM_ALLOWED_ACCESS,
|
|
&domain_sid,
|
|
&domain_pol);
|
|
else if (StrCaseCmp(argv[1], "builtin")==0)
|
|
result = rpccli_samr_OpenDomain(cli, mem_ctx,
|
|
&connect_pol,
|
|
MAXIMUM_ALLOWED_ACCESS,
|
|
CONST_DISCARD(struct dom_sid2 *, &global_sid_Builtin),
|
|
&domain_pol);
|
|
else
|
|
return NT_STATUS_OK;
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
/* Look up names */
|
|
|
|
num_names = argc - 2;
|
|
|
|
if ((names = TALLOC_ARRAY(mem_ctx, const char *, num_names)) == NULL) {
|
|
rpccli_samr_Close(cli, mem_ctx, &domain_pol);
|
|
rpccli_samr_Close(cli, mem_ctx, &connect_pol);
|
|
result = NT_STATUS_NO_MEMORY;
|
|
goto done;
|
|
}
|
|
|
|
for (i = 0; i < num_names; i++)
|
|
names[i] = argv[i + 2];
|
|
|
|
result = rpccli_samr_lookup_names(cli, mem_ctx, &domain_pol,
|
|
flags, num_names, names,
|
|
&num_rids, &rids, &name_types);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
/* Display results */
|
|
|
|
for (i = 0; i < num_names; i++)
|
|
printf("name %s: 0x%x (%d)\n", names[i], rids[i],
|
|
name_types[i]);
|
|
|
|
rpccli_samr_Close(cli, mem_ctx, &domain_pol);
|
|
rpccli_samr_Close(cli, mem_ctx, &connect_pol);
|
|
done:
|
|
return result;
|
|
}
|
|
|
|
/* Lookup sam rids */
|
|
|
|
static NTSTATUS cmd_samr_lookup_rids(struct rpc_pipe_client *cli,
|
|
TALLOC_CTX *mem_ctx,
|
|
int argc, const char **argv)
|
|
{
|
|
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
|
|
POLICY_HND connect_pol, domain_pol;
|
|
uint32 num_rids, num_names, *rids, *name_types;
|
|
char **names;
|
|
int i;
|
|
|
|
if (argc < 3) {
|
|
printf("Usage: %s domain|builtin rid1 [rid2 [rid3] [...]]\n", argv[0]);
|
|
return NT_STATUS_OK;
|
|
}
|
|
|
|
/* Get sam policy and domain handles */
|
|
|
|
result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
|
|
&connect_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
if (StrCaseCmp(argv[1], "domain")==0)
|
|
result = rpccli_samr_OpenDomain(cli, mem_ctx,
|
|
&connect_pol,
|
|
MAXIMUM_ALLOWED_ACCESS,
|
|
&domain_sid,
|
|
&domain_pol);
|
|
else if (StrCaseCmp(argv[1], "builtin")==0)
|
|
result = rpccli_samr_OpenDomain(cli, mem_ctx,
|
|
&connect_pol,
|
|
MAXIMUM_ALLOWED_ACCESS,
|
|
CONST_DISCARD(struct dom_sid2 *, &global_sid_Builtin),
|
|
&domain_pol);
|
|
else
|
|
return NT_STATUS_OK;
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
/* Look up rids */
|
|
|
|
num_rids = argc - 2;
|
|
|
|
if ((rids = TALLOC_ARRAY(mem_ctx, uint32, num_rids)) == NULL) {
|
|
rpccli_samr_Close(cli, mem_ctx, &domain_pol);
|
|
rpccli_samr_Close(cli, mem_ctx, &connect_pol);
|
|
result = NT_STATUS_NO_MEMORY;
|
|
goto done;
|
|
}
|
|
|
|
for (i = 0; i < argc - 2; i++)
|
|
sscanf(argv[i + 2], "%i", &rids[i]);
|
|
|
|
result = rpccli_samr_lookup_rids(cli, mem_ctx, &domain_pol, num_rids, rids,
|
|
&num_names, &names, &name_types);
|
|
|
|
if (!NT_STATUS_IS_OK(result) &&
|
|
!NT_STATUS_EQUAL(result, STATUS_SOME_UNMAPPED))
|
|
goto done;
|
|
|
|
/* Display results */
|
|
|
|
for (i = 0; i < num_names; i++)
|
|
printf("rid 0x%x: %s (%d)\n", rids[i], names[i], name_types[i]);
|
|
|
|
rpccli_samr_Close(cli, mem_ctx, &domain_pol);
|
|
rpccli_samr_Close(cli, mem_ctx, &connect_pol);
|
|
done:
|
|
return result;
|
|
}
|
|
|
|
/* Delete domain group */
|
|
|
|
static NTSTATUS cmd_samr_delete_dom_group(struct rpc_pipe_client *cli,
|
|
TALLOC_CTX *mem_ctx,
|
|
int argc, const char **argv)
|
|
{
|
|
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
|
|
POLICY_HND connect_pol, domain_pol, group_pol;
|
|
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
|
|
|
|
if ((argc < 2) || (argc > 3)) {
|
|
printf("Usage: %s groupname\n", argv[0]);
|
|
return NT_STATUS_OK;
|
|
}
|
|
|
|
if (argc > 2)
|
|
sscanf(argv[2], "%x", &access_mask);
|
|
|
|
/* Get sam policy and domain handles */
|
|
|
|
result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
|
|
&connect_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
result = rpccli_samr_OpenDomain(cli, mem_ctx,
|
|
&connect_pol,
|
|
MAXIMUM_ALLOWED_ACCESS,
|
|
&domain_sid,
|
|
&domain_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
/* Get handle on group */
|
|
|
|
{
|
|
uint32 *group_rids, num_rids, *name_types;
|
|
uint32 flags = 0x000003e8; /* Unknown */
|
|
|
|
result = rpccli_samr_lookup_names(cli, mem_ctx, &domain_pol,
|
|
flags, 1, (const char **)&argv[1],
|
|
&num_rids, &group_rids,
|
|
&name_types);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
result = rpccli_samr_OpenGroup(cli, mem_ctx,
|
|
&domain_pol,
|
|
access_mask,
|
|
group_rids[0],
|
|
&group_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
}
|
|
|
|
/* Delete group */
|
|
|
|
result = rpccli_samr_DeleteDomainGroup(cli, mem_ctx,
|
|
&group_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
/* Display results */
|
|
|
|
rpccli_samr_Close(cli, mem_ctx, &group_pol);
|
|
rpccli_samr_Close(cli, mem_ctx, &domain_pol);
|
|
rpccli_samr_Close(cli, mem_ctx, &connect_pol);
|
|
|
|
done:
|
|
return result;
|
|
}
|
|
|
|
/* Delete domain user */
|
|
|
|
static NTSTATUS cmd_samr_delete_dom_user(struct rpc_pipe_client *cli,
|
|
TALLOC_CTX *mem_ctx,
|
|
int argc, const char **argv)
|
|
{
|
|
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
|
|
POLICY_HND connect_pol, domain_pol, user_pol;
|
|
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
|
|
|
|
if ((argc < 2) || (argc > 3)) {
|
|
printf("Usage: %s username\n", argv[0]);
|
|
return NT_STATUS_OK;
|
|
}
|
|
|
|
if (argc > 2)
|
|
sscanf(argv[2], "%x", &access_mask);
|
|
|
|
/* Get sam policy and domain handles */
|
|
|
|
result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
|
|
&connect_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
result = rpccli_samr_OpenDomain(cli, mem_ctx,
|
|
&connect_pol,
|
|
MAXIMUM_ALLOWED_ACCESS,
|
|
&domain_sid,
|
|
&domain_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
/* Get handle on user */
|
|
|
|
{
|
|
uint32 *user_rids, num_rids, *name_types;
|
|
uint32 flags = 0x000003e8; /* Unknown */
|
|
|
|
result = rpccli_samr_lookup_names(cli, mem_ctx, &domain_pol,
|
|
flags, 1, (const char **)&argv[1],
|
|
&num_rids, &user_rids,
|
|
&name_types);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
result = rpccli_samr_OpenUser(cli, mem_ctx,
|
|
&domain_pol,
|
|
access_mask,
|
|
user_rids[0],
|
|
&user_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
}
|
|
|
|
/* Delete user */
|
|
|
|
result = rpccli_samr_DeleteUser(cli, mem_ctx,
|
|
&user_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
/* Display results */
|
|
|
|
rpccli_samr_Close(cli, mem_ctx, &user_pol);
|
|
rpccli_samr_Close(cli, mem_ctx, &domain_pol);
|
|
rpccli_samr_Close(cli, mem_ctx, &connect_pol);
|
|
|
|
done:
|
|
return result;
|
|
}
|
|
|
|
/**********************************************************************
|
|
* Query user security object
|
|
*/
|
|
static NTSTATUS cmd_samr_query_sec_obj(struct rpc_pipe_client *cli,
|
|
TALLOC_CTX *mem_ctx,
|
|
int argc, const char **argv)
|
|
{
|
|
POLICY_HND connect_pol, domain_pol, user_pol, *pol;
|
|
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
|
|
uint32 sec_info = DACL_SECURITY_INFORMATION;
|
|
fstring server;
|
|
uint32 user_rid = 0;
|
|
TALLOC_CTX *ctx = NULL;
|
|
SEC_DESC_BUF *sec_desc_buf=NULL;
|
|
bool domain = False;
|
|
|
|
ctx=talloc_init("cmd_samr_query_sec_obj");
|
|
|
|
if ((argc < 1) || (argc > 3)) {
|
|
printf("Usage: %s [rid|-d] [sec_info]\n", argv[0]);
|
|
printf("\tSpecify rid for security on user, -d for security on domain\n");
|
|
talloc_destroy(ctx);
|
|
return NT_STATUS_OK;
|
|
}
|
|
|
|
if (argc > 1) {
|
|
if (strcmp(argv[1], "-d") == 0)
|
|
domain = True;
|
|
else
|
|
sscanf(argv[1], "%i", &user_rid);
|
|
}
|
|
|
|
if (argc == 3) {
|
|
sec_info = atoi(argv[2]);
|
|
}
|
|
|
|
slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->cli->desthost);
|
|
strupper_m(server);
|
|
result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
|
|
&connect_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
if (domain || user_rid)
|
|
result = rpccli_samr_OpenDomain(cli, mem_ctx,
|
|
&connect_pol,
|
|
MAXIMUM_ALLOWED_ACCESS,
|
|
&domain_sid,
|
|
&domain_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
if (user_rid)
|
|
result = rpccli_samr_OpenUser(cli, mem_ctx,
|
|
&domain_pol,
|
|
MAXIMUM_ALLOWED_ACCESS,
|
|
user_rid,
|
|
&user_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
/* Pick which query pol to use */
|
|
|
|
pol = &connect_pol;
|
|
|
|
if (domain)
|
|
pol = &domain_pol;
|
|
|
|
if (user_rid)
|
|
pol = &user_pol;
|
|
|
|
/* Query SAM security object */
|
|
|
|
result = rpccli_samr_QuerySecurity(cli, mem_ctx,
|
|
pol,
|
|
sec_info,
|
|
&sec_desc_buf);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
display_sec_desc(sec_desc_buf->sd);
|
|
|
|
rpccli_samr_Close(cli, mem_ctx, &user_pol);
|
|
rpccli_samr_Close(cli, mem_ctx, &domain_pol);
|
|
rpccli_samr_Close(cli, mem_ctx, &connect_pol);
|
|
done:
|
|
talloc_destroy(ctx);
|
|
return result;
|
|
}
|
|
|
|
static NTSTATUS cmd_samr_get_usrdom_pwinfo(struct rpc_pipe_client *cli,
|
|
TALLOC_CTX *mem_ctx,
|
|
int argc, const char **argv)
|
|
{
|
|
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
|
|
POLICY_HND connect_pol, domain_pol, user_pol;
|
|
struct samr_PwInfo info;
|
|
uint32_t rid;
|
|
|
|
if (argc != 2) {
|
|
printf("Usage: %s rid\n", argv[0]);
|
|
return NT_STATUS_OK;
|
|
}
|
|
|
|
sscanf(argv[1], "%i", &rid);
|
|
|
|
result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
|
|
&connect_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result)) {
|
|
goto done;
|
|
}
|
|
|
|
result = rpccli_samr_OpenDomain(cli, mem_ctx,
|
|
&connect_pol,
|
|
MAXIMUM_ALLOWED_ACCESS,
|
|
&domain_sid,
|
|
&domain_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result)) {
|
|
goto done;
|
|
}
|
|
|
|
result = rpccli_samr_OpenUser(cli, mem_ctx,
|
|
&domain_pol,
|
|
MAXIMUM_ALLOWED_ACCESS,
|
|
rid,
|
|
&user_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result)) {
|
|
goto done;
|
|
}
|
|
|
|
result = rpccli_samr_GetUserPwInfo(cli, mem_ctx, &user_pol, &info);
|
|
if (NT_STATUS_IS_OK(result)) {
|
|
printf("min_password_length: %d\n", info.min_password_length);
|
|
printf("%s\n",
|
|
NDR_PRINT_STRUCT_STRING(mem_ctx,
|
|
samr_PasswordProperties, &info.password_properties));
|
|
}
|
|
|
|
done:
|
|
rpccli_samr_Close(cli, mem_ctx, &user_pol);
|
|
rpccli_samr_Close(cli, mem_ctx, &domain_pol);
|
|
rpccli_samr_Close(cli, mem_ctx, &connect_pol);
|
|
|
|
return result;
|
|
}
|
|
|
|
static NTSTATUS cmd_samr_get_dom_pwinfo(struct rpc_pipe_client *cli,
|
|
TALLOC_CTX *mem_ctx,
|
|
int argc, const char **argv)
|
|
{
|
|
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
|
|
struct lsa_String domain_name;
|
|
struct samr_PwInfo info;
|
|
|
|
if (argc < 1 || argc > 3) {
|
|
printf("Usage: %s <domain>\n", argv[0]);
|
|
return NT_STATUS_OK;
|
|
}
|
|
|
|
init_lsa_String(&domain_name, argv[1]);
|
|
|
|
result = rpccli_samr_GetDomPwInfo(cli, mem_ctx, &domain_name, &info);
|
|
|
|
if (NT_STATUS_IS_OK(result)) {
|
|
printf("min_password_length: %d\n", info.min_password_length);
|
|
display_password_properties(info.password_properties);
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
/* Look up domain name */
|
|
|
|
static NTSTATUS cmd_samr_lookup_domain(struct rpc_pipe_client *cli,
|
|
TALLOC_CTX *mem_ctx,
|
|
int argc, const char **argv)
|
|
{
|
|
POLICY_HND connect_pol, domain_pol;
|
|
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
|
|
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
|
|
fstring sid_string;
|
|
struct lsa_String domain_name;
|
|
DOM_SID *sid = NULL;
|
|
|
|
if (argc != 2) {
|
|
printf("Usage: %s domain_name\n", argv[0]);
|
|
return NT_STATUS_OK;
|
|
}
|
|
|
|
init_lsa_String(&domain_name, argv[1]);
|
|
|
|
result = try_samr_connects(cli, mem_ctx, access_mask, &connect_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
result = rpccli_samr_OpenDomain(cli, mem_ctx,
|
|
&connect_pol,
|
|
access_mask,
|
|
&domain_sid,
|
|
&domain_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
result = rpccli_samr_LookupDomain(cli, mem_ctx,
|
|
&connect_pol,
|
|
&domain_name,
|
|
&sid);
|
|
|
|
if (NT_STATUS_IS_OK(result)) {
|
|
sid_to_fstring(sid_string, sid);
|
|
printf("SAMR_LOOKUP_DOMAIN: Domain Name: %s Domain SID: %s\n",
|
|
argv[1], sid_string);
|
|
}
|
|
|
|
rpccli_samr_Close(cli, mem_ctx, &domain_pol);
|
|
rpccli_samr_Close(cli, mem_ctx, &connect_pol);
|
|
done:
|
|
return result;
|
|
}
|
|
|
|
/* Change user password */
|
|
|
|
static NTSTATUS cmd_samr_chgpasswd2(struct rpc_pipe_client *cli,
|
|
TALLOC_CTX *mem_ctx,
|
|
int argc, const char **argv)
|
|
{
|
|
POLICY_HND connect_pol, domain_pol;
|
|
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
|
|
const char *user, *oldpass, *newpass;
|
|
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
|
|
|
|
if (argc < 3) {
|
|
printf("Usage: %s username oldpass newpass\n", argv[0]);
|
|
return NT_STATUS_INVALID_PARAMETER;
|
|
}
|
|
|
|
user = argv[1];
|
|
oldpass = argv[2];
|
|
newpass = argv[3];
|
|
|
|
/* Get sam policy handle */
|
|
|
|
result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
|
|
&connect_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
/* Get domain policy handle */
|
|
|
|
result = rpccli_samr_OpenDomain(cli, mem_ctx,
|
|
&connect_pol,
|
|
access_mask,
|
|
&domain_sid,
|
|
&domain_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
/* Change user password */
|
|
result = rpccli_samr_chgpasswd_user(cli, mem_ctx, user, newpass, oldpass);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
result = rpccli_samr_Close(cli, mem_ctx, &domain_pol);
|
|
if (!NT_STATUS_IS_OK(result)) goto done;
|
|
|
|
result = rpccli_samr_Close(cli, mem_ctx, &connect_pol);
|
|
if (!NT_STATUS_IS_OK(result)) goto done;
|
|
|
|
done:
|
|
return result;
|
|
}
|
|
|
|
|
|
/* Change user password */
|
|
|
|
static NTSTATUS cmd_samr_chgpasswd3(struct rpc_pipe_client *cli,
|
|
TALLOC_CTX *mem_ctx,
|
|
int argc, const char **argv)
|
|
{
|
|
POLICY_HND connect_pol, domain_pol;
|
|
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
|
|
const char *user, *oldpass, *newpass;
|
|
uint32 access_mask = MAXIMUM_ALLOWED_ACCESS;
|
|
struct samr_DomInfo1 *info = NULL;
|
|
struct samr_ChangeReject *reject = NULL;
|
|
|
|
if (argc < 3) {
|
|
printf("Usage: %s username oldpass newpass\n", argv[0]);
|
|
return NT_STATUS_INVALID_PARAMETER;
|
|
}
|
|
|
|
user = argv[1];
|
|
oldpass = argv[2];
|
|
newpass = argv[3];
|
|
|
|
/* Get sam policy handle */
|
|
|
|
result = try_samr_connects(cli, mem_ctx, MAXIMUM_ALLOWED_ACCESS,
|
|
&connect_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
/* Get domain policy handle */
|
|
|
|
result = rpccli_samr_OpenDomain(cli, mem_ctx,
|
|
&connect_pol,
|
|
access_mask,
|
|
&domain_sid,
|
|
&domain_pol);
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
/* Change user password */
|
|
result = rpccli_samr_chgpasswd3(cli, mem_ctx,
|
|
user,
|
|
newpass,
|
|
oldpass,
|
|
&info,
|
|
&reject);
|
|
|
|
if (NT_STATUS_EQUAL(result, NT_STATUS_PASSWORD_RESTRICTION)) {
|
|
|
|
display_sam_dom_info_1(info);
|
|
|
|
switch (reject->reason) {
|
|
case SAMR_REJECT_TOO_SHORT:
|
|
d_printf("SAMR_REJECT_TOO_SHORT\n");
|
|
break;
|
|
case SAMR_REJECT_IN_HISTORY:
|
|
d_printf("SAMR_REJECT_IN_HISTORY\n");
|
|
break;
|
|
case SAMR_REJECT_COMPLEXITY:
|
|
d_printf("SAMR_REJECT_COMPLEXITY\n");
|
|
break;
|
|
case SAMR_REJECT_OTHER:
|
|
d_printf("SAMR_REJECT_OTHER\n");
|
|
break;
|
|
default:
|
|
d_printf("unknown reject reason: %d\n",
|
|
reject->reason);
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!NT_STATUS_IS_OK(result))
|
|
goto done;
|
|
|
|
result = rpccli_samr_Close(cli, mem_ctx, &domain_pol);
|
|
if (!NT_STATUS_IS_OK(result)) goto done;
|
|
|
|
result = rpccli_samr_Close(cli, mem_ctx, &connect_pol);
|
|
if (!NT_STATUS_IS_OK(result)) goto done;
|
|
|
|
done:
|
|
return result;
|
|
}
|
|
|
|
/* List of commands exported by this module */
|
|
|
|
struct cmd_set samr_commands[] = {
|
|
|
|
{ "SAMR" },
|
|
|
|
{ "queryuser", RPC_RTYPE_NTSTATUS, cmd_samr_query_user, NULL, PI_SAMR, NULL, "Query user info", "" },
|
|
{ "querygroup", RPC_RTYPE_NTSTATUS, cmd_samr_query_group, NULL, PI_SAMR, NULL, "Query group info", "" },
|
|
{ "queryusergroups", RPC_RTYPE_NTSTATUS, cmd_samr_query_usergroups, NULL, PI_SAMR, NULL, "Query user groups", "" },
|
|
{ "queryuseraliases", RPC_RTYPE_NTSTATUS, cmd_samr_query_useraliases, NULL, PI_SAMR, NULL, "Query user aliases", "" },
|
|
{ "querygroupmem", RPC_RTYPE_NTSTATUS, cmd_samr_query_groupmem, NULL, PI_SAMR, NULL, "Query group membership", "" },
|
|
{ "queryaliasmem", RPC_RTYPE_NTSTATUS, cmd_samr_query_aliasmem, NULL, PI_SAMR, NULL, "Query alias membership", "" },
|
|
{ "queryaliasinfo", RPC_RTYPE_NTSTATUS, cmd_samr_query_aliasinfo, NULL, PI_SAMR, NULL, "Query alias info", "" },
|
|
{ "deletealias", RPC_RTYPE_NTSTATUS, cmd_samr_delete_alias, NULL, PI_SAMR, NULL, "Delete an alias", "" },
|
|
{ "querydispinfo", RPC_RTYPE_NTSTATUS, cmd_samr_query_dispinfo, NULL, PI_SAMR, NULL, "Query display info", "" },
|
|
{ "querydominfo", RPC_RTYPE_NTSTATUS, cmd_samr_query_dominfo, NULL, PI_SAMR, NULL, "Query domain info", "" },
|
|
{ "enumdomusers", RPC_RTYPE_NTSTATUS, cmd_samr_enum_dom_users, NULL, PI_SAMR, NULL, "Enumerate domain users", "" },
|
|
{ "enumdomgroups", RPC_RTYPE_NTSTATUS, cmd_samr_enum_dom_groups, NULL, PI_SAMR, NULL, "Enumerate domain groups", "" },
|
|
{ "enumalsgroups", RPC_RTYPE_NTSTATUS, cmd_samr_enum_als_groups, NULL, PI_SAMR, NULL, "Enumerate alias groups", "" },
|
|
|
|
{ "createdomuser", RPC_RTYPE_NTSTATUS, cmd_samr_create_dom_user, NULL, PI_SAMR, NULL, "Create domain user", "" },
|
|
{ "createdomgroup", RPC_RTYPE_NTSTATUS, cmd_samr_create_dom_group, NULL, PI_SAMR, NULL, "Create domain group", "" },
|
|
{ "createdomalias", RPC_RTYPE_NTSTATUS, cmd_samr_create_dom_alias, NULL, PI_SAMR, NULL, "Create domain alias", "" },
|
|
{ "samlookupnames", RPC_RTYPE_NTSTATUS, cmd_samr_lookup_names, NULL, PI_SAMR, NULL, "Look up names", "" },
|
|
{ "samlookuprids", RPC_RTYPE_NTSTATUS, cmd_samr_lookup_rids, NULL, PI_SAMR, NULL, "Look up names", "" },
|
|
{ "deletedomgroup", RPC_RTYPE_NTSTATUS, cmd_samr_delete_dom_group, NULL, PI_SAMR, NULL, "Delete domain group", "" },
|
|
{ "deletedomuser", RPC_RTYPE_NTSTATUS, cmd_samr_delete_dom_user, NULL, PI_SAMR, NULL, "Delete domain user", "" },
|
|
{ "samquerysecobj", RPC_RTYPE_NTSTATUS, cmd_samr_query_sec_obj, NULL, PI_SAMR, NULL, "Query SAMR security object", "" },
|
|
{ "getdompwinfo", RPC_RTYPE_NTSTATUS, cmd_samr_get_dom_pwinfo, NULL, PI_SAMR, NULL, "Retrieve domain password info", "" },
|
|
{ "getusrdompwinfo", RPC_RTYPE_NTSTATUS, cmd_samr_get_usrdom_pwinfo, NULL, PI_SAMR, NULL, "Retrieve user domain password info", "" },
|
|
|
|
{ "lookupdomain", RPC_RTYPE_NTSTATUS, cmd_samr_lookup_domain, NULL, PI_SAMR, NULL, "Lookup Domain Name", "" },
|
|
{ "chgpasswd2", RPC_RTYPE_NTSTATUS, cmd_samr_chgpasswd2, NULL, PI_SAMR, NULL, "Change user password", "" },
|
|
{ "chgpasswd3", RPC_RTYPE_NTSTATUS, cmd_samr_chgpasswd3, NULL, PI_SAMR, NULL, "Change user password", "" },
|
|
{ NULL }
|
|
};
|