From 39c367b8e9932f64fa774b807e14416f97254312 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Fri, 1 Oct 1999 18:44:33 +0000 Subject: [PATCH] splitting dom info into sam_query_dominfo function --- source/include/proto.h | 2 + source/rpc_parse/parse_samr.c | 5 +- source/rpcclient/cmd_samr.c | 94 +++++++++++++++++++++-------------- 3 files changed, 63 insertions(+), 38 deletions(-) diff --git a/source/include/proto.h b/source/include/proto.h index 4326cb4762d..5172dfb495b 100644 --- a/source/include/proto.h +++ b/source/include/proto.h @@ -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_query_user(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_enum_aliases(struct client_info *info); void cmd_sam_enum_groups(struct client_info *info); diff --git a/source/rpc_parse/parse_samr.c b/source/rpc_parse/parse_samr.c index ccc9cdc183c..e5c015a6b3f 100644 --- a/source/rpc_parse/parse_samr.c +++ b/source/rpc_parse/parse_samr.c @@ -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_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) { + prs_uint16("switch_value", ps, depth, &(r_u->switch_value)); + prs_align(ps); + switch (r_u->switch_value) { case 0x07: diff --git a/source/rpcclient/cmd_samr.c b/source/rpcclient/cmd_samr.c index a14c2d29bd6..130790e4160 100644 --- a/source/rpcclient/cmd_samr.c +++ b/source/rpcclient/cmd_samr.c @@ -1666,17 +1666,69 @@ void cmd_sam_query_dispinfo(struct client_info *info) /**************************************************************************** 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; 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 sid; DOM_SID sid1; - BOOL res = True; fstring info_str; uint32 switch_value = 2; - uint32 ace_perms = 0x02000000; /* absolutely no idea. */ SAM_UNK_CTR ctr; 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); - fstrcpy(srv_name, "\\\\"); - fstrcat(srv_name, info->dest_host); - strupper(srv_name); - if (next_token(NULL, info_str, NULL, sizeof(info_str))) { switch_value = strtoul(info_str, (char**)NULL, 10); } 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", - info->myhostname, srv_name, domain, sid); + report(out_hnd, "From: %s Domain: %s SID: %s\n", + info->myhostname, domain, sid); - /* 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 */ - 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) + if (sam_query_dominfo(info, &sid1, switch_value, &ctr)) { DEBUG(5,("cmd_sam_query_dominfo: succeeded\n")); display_sam_unk_ctr(out_hnd, ACTION_HEADER , switch_value, &ctr);