mirror of
https://github.com/samba-team/samba.git
synced 2025-07-30 19:42:05 +03:00
splitting dom info into sam_query_dominfo function
This commit is contained in:
@ -3183,6 +3183,8 @@ int msrpc_sam_enum_users(struct client_info *info,
|
|||||||
void cmd_sam_enum_users(struct client_info *info);
|
void cmd_sam_enum_users(struct client_info *info);
|
||||||
void cmd_sam_query_user(struct client_info *info);
|
void cmd_sam_query_user(struct client_info *info);
|
||||||
void cmd_sam_query_dispinfo(struct client_info *info);
|
void cmd_sam_query_dispinfo(struct client_info *info);
|
||||||
|
BOOL sam_query_dominfo(struct client_info *info, DOM_SID *sid1,
|
||||||
|
uint32 switch_value, SAM_UNK_CTR *ctr);
|
||||||
void cmd_sam_query_dominfo(struct client_info *info);
|
void cmd_sam_query_dominfo(struct client_info *info);
|
||||||
void cmd_sam_enum_aliases(struct client_info *info);
|
void cmd_sam_enum_aliases(struct client_info *info);
|
||||||
void cmd_sam_enum_groups(struct client_info *info);
|
void cmd_sam_enum_groups(struct client_info *info);
|
||||||
|
@ -543,11 +543,12 @@ void samr_io_r_query_dom_info(char *desc, SAMR_R_QUERY_DOMAIN_INFO *r_u, prs_str
|
|||||||
prs_align(ps);
|
prs_align(ps);
|
||||||
|
|
||||||
prs_uint32("ptr_0 ", ps, depth, &(r_u->ptr_0));
|
prs_uint32("ptr_0 ", ps, depth, &(r_u->ptr_0));
|
||||||
prs_uint16("switch_value", ps, depth, &(r_u->switch_value));
|
|
||||||
prs_align(ps);
|
|
||||||
|
|
||||||
if (r_u->ptr_0 != 0 && r_u->ctr != NULL)
|
if (r_u->ptr_0 != 0 && r_u->ctr != NULL)
|
||||||
{
|
{
|
||||||
|
prs_uint16("switch_value", ps, depth, &(r_u->switch_value));
|
||||||
|
prs_align(ps);
|
||||||
|
|
||||||
switch (r_u->switch_value)
|
switch (r_u->switch_value)
|
||||||
{
|
{
|
||||||
case 0x07:
|
case 0x07:
|
||||||
|
@ -1666,17 +1666,69 @@ void cmd_sam_query_dispinfo(struct client_info *info)
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
experimental SAM domain info query.
|
experimental SAM domain info query.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
void cmd_sam_query_dominfo(struct client_info *info)
|
BOOL sam_query_dominfo(struct client_info *info, DOM_SID *sid1,
|
||||||
|
uint32 switch_value, SAM_UNK_CTR *ctr)
|
||||||
{
|
{
|
||||||
uint16 fnum;
|
uint16 fnum;
|
||||||
fstring srv_name;
|
fstring srv_name;
|
||||||
|
BOOL res = True;
|
||||||
|
BOOL res1 = True;
|
||||||
|
BOOL res2 = True;
|
||||||
|
uint32 ace_perms = 0x02000000; /* absolutely no idea. */
|
||||||
|
|
||||||
|
fstrcpy(srv_name, "\\\\");
|
||||||
|
fstrcat(srv_name, info->dest_host);
|
||||||
|
strupper(srv_name);
|
||||||
|
|
||||||
|
/* open SAMR session. negotiate credentials */
|
||||||
|
res = res ? cli_nt_session_open(smb_cli, PIPE_SAMR, &fnum) : False;
|
||||||
|
|
||||||
|
/* establish a connection. */
|
||||||
|
res = res ? samr_connect(smb_cli, fnum,
|
||||||
|
srv_name, 0x02000000,
|
||||||
|
&info->dom.samr_pol_connect) : False;
|
||||||
|
|
||||||
|
/* connect to the domain */
|
||||||
|
res1 = res ? samr_open_domain(smb_cli, fnum,
|
||||||
|
&info->dom.samr_pol_connect, ace_perms, sid1,
|
||||||
|
&info->dom.samr_pol_open_domain) : False;
|
||||||
|
|
||||||
|
/* send a samr 0x8 command */
|
||||||
|
res2 = res ? samr_query_dom_info(smb_cli, fnum,
|
||||||
|
&info->dom.samr_pol_open_domain, switch_value, ctr) : False;
|
||||||
|
|
||||||
|
res1 = res1 ? samr_close(smb_cli, fnum,
|
||||||
|
&info->dom.samr_pol_connect) : False;
|
||||||
|
|
||||||
|
res = res ? samr_close(smb_cli, fnum,
|
||||||
|
&info->dom.samr_pol_open_domain) : False;
|
||||||
|
|
||||||
|
/* close the session */
|
||||||
|
cli_nt_session_close(smb_cli, fnum);
|
||||||
|
|
||||||
|
if (res2)
|
||||||
|
{
|
||||||
|
DEBUG(5,("sam_query_dominfo: succeeded\n"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DEBUG(5,("sam_query_dominfo: failed\n"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return res2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
experimental SAM domain info query.
|
||||||
|
****************************************************************************/
|
||||||
|
void cmd_sam_query_dominfo(struct client_info *info)
|
||||||
|
{
|
||||||
fstring domain;
|
fstring domain;
|
||||||
fstring sid;
|
fstring sid;
|
||||||
DOM_SID sid1;
|
DOM_SID sid1;
|
||||||
BOOL res = True;
|
|
||||||
fstring info_str;
|
fstring info_str;
|
||||||
uint32 switch_value = 2;
|
uint32 switch_value = 2;
|
||||||
uint32 ace_perms = 0x02000000; /* absolutely no idea. */
|
|
||||||
SAM_UNK_CTR ctr;
|
SAM_UNK_CTR ctr;
|
||||||
|
|
||||||
sid_to_string(sid, &info->dom.level5_sid);
|
sid_to_string(sid, &info->dom.level5_sid);
|
||||||
@ -1690,46 +1742,16 @@ void cmd_sam_query_dominfo(struct client_info *info)
|
|||||||
|
|
||||||
string_to_sid(&sid1, sid);
|
string_to_sid(&sid1, sid);
|
||||||
|
|
||||||
fstrcpy(srv_name, "\\\\");
|
|
||||||
fstrcat(srv_name, info->dest_host);
|
|
||||||
strupper(srv_name);
|
|
||||||
|
|
||||||
if (next_token(NULL, info_str, NULL, sizeof(info_str)))
|
if (next_token(NULL, info_str, NULL, sizeof(info_str)))
|
||||||
{
|
{
|
||||||
switch_value = strtoul(info_str, (char**)NULL, 10);
|
switch_value = strtoul(info_str, (char**)NULL, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
report(out_hnd, "SAM Query Domain Info: info level %d\n", switch_value);
|
report(out_hnd, "SAM Query Domain Info: info level %d\n", switch_value);
|
||||||
report(out_hnd, "From: %s To: %s Domain: %s SID: %s\n",
|
report(out_hnd, "From: %s Domain: %s SID: %s\n",
|
||||||
info->myhostname, srv_name, domain, sid);
|
info->myhostname, domain, sid);
|
||||||
|
|
||||||
/* open SAMR session. negotiate credentials */
|
if (sam_query_dominfo(info, &sid1, switch_value, &ctr))
|
||||||
res = res ? cli_nt_session_open(smb_cli, PIPE_SAMR, &fnum) : False;
|
|
||||||
|
|
||||||
/* establish a connection. */
|
|
||||||
res = res ? samr_connect(smb_cli, fnum,
|
|
||||||
srv_name, 0x02000000,
|
|
||||||
&info->dom.samr_pol_connect) : False;
|
|
||||||
|
|
||||||
/* connect to the domain */
|
|
||||||
res = res ? samr_open_domain(smb_cli, fnum,
|
|
||||||
&info->dom.samr_pol_connect, ace_perms, &sid1,
|
|
||||||
&info->dom.samr_pol_open_domain) : False;
|
|
||||||
|
|
||||||
/* send a samr 0x8 command */
|
|
||||||
res = res ? samr_query_dom_info(smb_cli, fnum,
|
|
||||||
&info->dom.samr_pol_open_domain, switch_value, &ctr) : False;
|
|
||||||
|
|
||||||
res = res ? samr_close(smb_cli, fnum,
|
|
||||||
&info->dom.samr_pol_connect) : False;
|
|
||||||
|
|
||||||
res = res ? samr_close(smb_cli, fnum,
|
|
||||||
&info->dom.samr_pol_open_domain) : False;
|
|
||||||
|
|
||||||
/* close the session */
|
|
||||||
cli_nt_session_close(smb_cli, fnum);
|
|
||||||
|
|
||||||
if (res)
|
|
||||||
{
|
{
|
||||||
DEBUG(5,("cmd_sam_query_dominfo: succeeded\n"));
|
DEBUG(5,("cmd_sam_query_dominfo: succeeded\n"));
|
||||||
display_sam_unk_ctr(out_hnd, ACTION_HEADER , switch_value, &ctr);
|
display_sam_unk_ctr(out_hnd, ACTION_HEADER , switch_value, &ctr);
|
||||||
|
Reference in New Issue
Block a user