summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/include/proto.h2
-rw-r--r--source3/rpc_parse/parse_samr.c5
-rw-r--r--source3/rpcclient/cmd_samr.c88
3 files changed, 60 insertions, 35 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 4326cb4762..5172dfb495 100644
--- a/source3/include/proto.h
+++ b/source3/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/source3/rpc_parse/parse_samr.c b/source3/rpc_parse/parse_samr.c
index ccc9cdc183..e5c015a6b3 100644
--- a/source3/rpc_parse/parse_samr.c
+++ b/source3/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/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c
index a14c2d29bd..130790e416 100644
--- a/source3/rpcclient/cmd_samr.c
+++ b/source3/rpcclient/cmd_samr.c
@@ -1666,43 +1666,20 @@ 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;
- fstring domain;
- fstring sid;
- DOM_SID sid1;
BOOL res = True;
- fstring info_str;
- uint32 switch_value = 2;
+ BOOL res1 = True;
+ BOOL res2 = True;
uint32 ace_perms = 0x02000000; /* absolutely no idea. */
- SAM_UNK_CTR ctr;
-
- sid_to_string(sid, &info->dom.level5_sid);
- fstrcpy(domain, info->dom.level5_dom);
-
- if (strlen(sid) == 0)
- {
- report(out_hnd, "please use 'lsaquery' first, to ascertain the SID\n");
- return;
- }
-
- 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);
-
/* open SAMR session. negotiate credentials */
res = res ? cli_nt_session_open(smb_cli, PIPE_SAMR, &fnum) : False;
@@ -1712,15 +1689,15 @@ void cmd_sam_query_dominfo(struct client_info *info)
&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,
+ 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 */
- res = res ? samr_query_dom_info(smb_cli, fnum,
- &info->dom.samr_pol_open_domain, switch_value, &ctr) : False;
+ res2 = 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,
+ res1 = res1 ? samr_close(smb_cli, fnum,
&info->dom.samr_pol_connect) : False;
res = res ? samr_close(smb_cli, fnum,
@@ -1729,7 +1706,52 @@ void cmd_sam_query_dominfo(struct client_info *info)
/* close the session */
cli_nt_session_close(smb_cli, fnum);
- if (res)
+ 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;
+ fstring info_str;
+ uint32 switch_value = 2;
+ SAM_UNK_CTR ctr;
+
+ sid_to_string(sid, &info->dom.level5_sid);
+ fstrcpy(domain, info->dom.level5_dom);
+
+ if (strlen(sid) == 0)
+ {
+ report(out_hnd, "please use 'lsaquery' first, to ascertain the SID\n");
+ return;
+ }
+
+ string_to_sid(&sid1, sid);
+
+ 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 Domain: %s SID: %s\n",
+ info->myhostname, domain, sid);
+
+ 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);