summaryrefslogtreecommitdiff
path: root/source3/rpcclient/cmd_lsarpc.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/rpcclient/cmd_lsarpc.c')
-rw-r--r--source3/rpcclient/cmd_lsarpc.c90
1 files changed, 54 insertions, 36 deletions
diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c
index 6dc50c5c22..a23e7a650b 100644
--- a/source3/rpcclient/cmd_lsarpc.c
+++ b/source3/rpcclient/cmd_lsarpc.c
@@ -49,9 +49,9 @@ void cmd_lsa_query_info(struct client_info *info)
BOOL res = True;
fstrcpy(info->dom.level3_dom, "");
- fstrcpy(info->dom.level3_sid, "");
fstrcpy(info->dom.level5_dom, "");
- fstrcpy(info->dom.level5_sid, "");
+ ZERO_STRUCT(info->dom.level3_sid);
+ ZERO_STRUCT(info->dom.level5_sid);
fstrcpy(srv_name, "\\\\");
fstrcat(srv_name, info->myhostname);
@@ -71,15 +71,15 @@ void cmd_lsa_query_info(struct client_info *info)
/* send client info query, level 3. receive domain name and sid */
res = res ? do_lsa_query_info_pol(smb_cli,
- &info->dom.lsa_info_pol, 0x03,
- info->dom.level3_dom,
- info->dom.level3_sid) : False;
+ &info->dom.lsa_info_pol, 0x03,
+ info->dom.level3_dom,
+ &info->dom.level3_sid) : False;
/* send client info query, level 5. receive domain name and sid */
res = res ? do_lsa_query_info_pol(smb_cli,
- &info->dom.lsa_info_pol, 0x05,
+ &info->dom.lsa_info_pol, 0x05,
info->dom.level5_dom,
- info->dom.level5_sid) : False;
+ &info->dom.level5_sid) : False;
res = res ? do_lsa_close(smb_cli, &info->dom.lsa_info_pol) : False;
@@ -89,20 +89,23 @@ void cmd_lsa_query_info(struct client_info *info)
if (res)
{
BOOL domain_something = False;
+ fstring sid;
DEBUG(5,("cmd_lsa_query_info: query succeeded\n"));
fprintf(out_hnd, "LSA Query Info Policy\n");
- if (info->dom.level3_sid[0] != 0)
+ if (info->dom.level3_dom[0] != 0)
{
+ sid_to_string(sid, &info->dom.level3_sid);
fprintf(out_hnd, "Domain Member - Domain: %s SID: %s\n",
- info->dom.level3_dom, info->dom.level3_sid);
+ info->dom.level3_dom, sid);
domain_something = True;
}
- if (info->dom.level5_sid[0] != 0)
+ if (info->dom.level5_dom[0] != 0)
{
+ sid_to_string(sid, &info->dom.level5_sid);
fprintf(out_hnd, "Domain Controller - Domain: %s SID: %s\n",
- info->dom.level5_dom, info->dom.level5_sid);
+ info->dom.level5_dom, sid);
domain_something = True;
}
if (!domain_something)
@@ -123,53 +126,53 @@ nt lsa query
void cmd_lsa_lookup_sids(struct client_info *info)
{
fstring temp;
- fstring sid_name;
+ int i;
+ pstring sid_name;
fstring srv_name;
- DOM_SID sid;
- DOM_SID *sids[1];
+ DOM_SID sid[10];
+ DOM_SID *sids[10];
+ int num_sids = 0;
char **names = NULL;
+ int num_names = 0;
BOOL res = True;
- DEBUG(5, ("cmd_lsa_lookup_sids: smb_cli->fd:%d\n", smb_cli->fd));
-
fstrcpy(srv_name, "\\\\");
fstrcat(srv_name, info->myhostname);
strupper(srv_name);
- fstrcpy(sid_name, info->dom.level5_sid);
+ DEBUG(4,("cmd_lsa_lookup_sids: server: %s\n", srv_name));
- if (next_token(NULL, temp, NULL, sizeof(temp)))
+ while (num_sids < 10 && next_token(NULL, temp, NULL, sizeof(temp)))
{
- if (info->dom.level5_sid[0] == 0)
- {
- fprintf(out_hnd, "please use lsaquery first or specify a complete SID\n");
- return;
- }
-
if (strnequal("S-", temp, 2))
{
fstrcpy(sid_name, temp);
}
else
{
+ sid_to_string(sid_name, &info->dom.level5_sid);
+
+ if (sid_name[0] == 0)
+ {
+ fprintf(out_hnd, "please use lsaquery first or specify a complete SID\n");
+ return;
+ }
+
fstrcat(sid_name, "-");
fstrcat(sid_name, temp);
}
+ make_dom_sid(&sid[num_sids], sid_name);
+ sids[num_sids] = &sid[num_sids];
+ num_sids++;
}
- else
+
+ if (num_sids == 0)
{
- fprintf(out_hnd, "lsalookup RID or SID\n");
+ fprintf(out_hnd, "lookupsid RID or SID\n");
return;
}
- DEBUG(4,("cmd_lsa_lookup_sids: server: %s sid:%s\n",
- srv_name, sid_name));
-
- make_dom_sid(&sid, sid_name);
-
- sids[0] = &sid;
-
/* open LSARPC session. */
res = res ? cli_nt_session_open(smb_cli, PIPE_LSARPC) : False;
@@ -178,9 +181,11 @@ void cmd_lsa_lookup_sids(struct client_info *info)
srv_name,
&info->dom.lsa_info_pol, True) : False;
- /* send client info query, level 3. receive domain name and sid */
+ /* send lsa lookup sids call */
res = res ? do_lsa_lookup_sids(smb_cli,
- &info->dom.lsa_info_pol, 1, sids, names) : False;
+ &info->dom.lsa_info_pol,
+ num_sids, sids,
+ &names, &num_names) : False;
res = res ? do_lsa_close(smb_cli, &info->dom.lsa_info_pol) : False;
@@ -190,11 +195,24 @@ void cmd_lsa_lookup_sids(struct client_info *info)
if (res)
{
DEBUG(5,("cmd_lsa_lookup_sids: query succeeded\n"));
-
}
else
{
DEBUG(5,("cmd_lsa_lookup_sids: query failed\n"));
}
+ if (names != NULL)
+ {
+ fprintf(out_hnd,"Lookup SIDS:\n");
+ for (i = 0; i < num_names; i++)
+ {
+ sid_to_string(temp, sids[i]);
+ fprintf(out_hnd, "SID: %s -> %s\n", temp, names[i]);
+ if (names[i] != NULL)
+ {
+ free(names[i]);
+ }
+ }
+ free(names);
+ }
}