summaryrefslogtreecommitdiff
path: root/source3/rpcclient/cmd_samr.c
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>1999-11-02 23:47:17 +0000
committerLuke Leighton <lkcl@samba.org>1999-11-02 23:47:17 +0000
commit37983b979fc99272eef1c61c93294e93c3c1c714 (patch)
treeadf039ac2d5122c5ff424177faa27be06c9e7f2d /source3/rpcclient/cmd_samr.c
parent70115706101a11b32f598b80731468a9ce4bfb87 (diff)
downloadsamba-37983b979fc99272eef1c61c93294e93c3c1c714.tar.gz
samba-37983b979fc99272eef1c61c93294e93c3c1c714.tar.bz2
samba-37983b979fc99272eef1c61c93294e93c3c1c714.zip
added samalias <aliasname> rpcclient command (shows info on alias)
added samaliasmem <aliasname> rpcclient command (shows members in alias) added tab command-completion to SAM alias related commands (inc 2 above). (This used to be commit 0c700fb609adf80cb3191f2976c6d56088d81232)
Diffstat (limited to 'source3/rpcclient/cmd_samr.c')
-rw-r--r--source3/rpcclient/cmd_samr.c197
1 files changed, 193 insertions, 4 deletions
diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c
index 056a3292a9..4ed82fbe28 100644
--- a/source3/rpcclient/cmd_samr.c
+++ b/source3/rpcclient/cmd_samr.c
@@ -925,10 +925,6 @@ uint32 msrpc_sam_enum_aliases(struct client_info *info,
fstrcat(srv_name, info->dest_host);
strupper(srv_name);
- report(out_hnd, "SAM Enumerate Aliases\n");
- 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;
@@ -2648,6 +2644,199 @@ void cmd_sam_query_dominfo(struct client_info *info)
}
/****************************************************************************
+experimental SAM alias query members.
+****************************************************************************/
+void cmd_sam_query_aliasmem(struct client_info *info)
+{
+ uint16 fnum;
+ fstring srv_name;
+ fstring domain;
+ fstring sid_str;
+ DOM_SID sid;
+ BOOL res = True;
+ BOOL res1 = True;
+
+ fstring alias_name;
+ char *names[1];
+ uint32 num_rids;
+ uint32 rid[MAX_LOOKUP_SIDS];
+ uint32 type[MAX_LOOKUP_SIDS];
+ POLICY_HND sam_pol;
+ POLICY_HND pol_dom;
+
+ fstrcpy(domain, info->dom.level5_dom);
+ sid_copy(&sid, &info->dom.level5_sid);
+
+ if (sid.num_auths == 0)
+ {
+ report(out_hnd, "please use 'lsaquery' first, to ascertain the SID\n");
+ return;
+ }
+
+ if (!next_token(NULL, alias_name, NULL, sizeof(alias_name)))
+ {
+ report(out_hnd, "samalias <name>\n");
+ return;
+ }
+
+ fstrcpy(srv_name, "\\\\");
+ fstrcat(srv_name, info->dest_host);
+ strupper(srv_name);
+
+ sid_to_string(sid_str, &sid);
+
+ report(out_hnd, "SAM Query Alias: %s\n", alias_name);
+ report(out_hnd, "From: %s To: %s Domain: %s SID: %s\n",
+ info->myhostname, srv_name, domain, sid_str);
+
+ /* 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,
+ &sam_pol) : False;
+
+ /* connect to the domain */
+ res = res ? samr_open_domain(smb_cli, fnum,
+ &sam_pol, 0x304, &sid,
+ &pol_dom) : False;
+
+ /* look up alias rid */
+ names[0] = alias_name;
+ res1 = res ? samr_query_lookup_names(smb_cli, fnum,
+ &pol_dom, 0x3e8,
+ 1, names,
+ &num_rids, rid, type) : False;
+
+ if (res1 && num_rids == 1)
+ {
+ res1 = req_aliasmem_info(smb_cli, fnum,
+ &pol_dom,
+ domain,
+ &sid,
+ rid[0],
+ names[0],
+ sam_display_alias_members);
+ }
+
+ res = res ? samr_close(smb_cli, fnum,
+ &sam_pol) : False;
+
+ res = res ? samr_close(smb_cli, fnum,
+ &pol_dom) : False;
+
+ /* close the session */
+ cli_nt_session_close(smb_cli, fnum);
+
+ if (res1)
+ {
+ DEBUG(5,("cmd_sam_query_alias: succeeded\n"));
+ }
+ else
+ {
+ DEBUG(5,("cmd_sam_query_alias: failed\n"));
+ }
+}
+
+
+/****************************************************************************
+experimental SAM alias query.
+****************************************************************************/
+void cmd_sam_query_alias(struct client_info *info)
+{
+ uint16 fnum;
+ fstring srv_name;
+ fstring domain;
+ fstring sid_str;
+ DOM_SID sid;
+ BOOL res = True;
+ BOOL res1 = True;
+
+ fstring alias_name;
+ char *names[1];
+ uint32 num_rids;
+ uint32 rid[MAX_LOOKUP_SIDS];
+ uint32 type[MAX_LOOKUP_SIDS];
+ POLICY_HND sam_pol;
+ POLICY_HND pol_dom;
+
+ fstrcpy(domain, info->dom.level5_dom);
+ sid_copy(&sid, &info->dom.level5_sid);
+
+ if (sid.num_auths == 0)
+ {
+ report(out_hnd, "please use 'lsaquery' first, to ascertain the SID\n");
+ return;
+ }
+
+ if (!next_token(NULL, alias_name, NULL, sizeof(alias_name)))
+ {
+ report(out_hnd, "samalias <name>\n");
+ return;
+ }
+
+ fstrcpy(srv_name, "\\\\");
+ fstrcat(srv_name, info->dest_host);
+ strupper(srv_name);
+
+ sid_to_string(sid_str, &sid);
+
+ report(out_hnd, "SAM Query Alias: %s\n", alias_name);
+ report(out_hnd, "From: %s To: %s Domain: %s SID: %s\n",
+ info->myhostname, srv_name, domain, sid_str);
+
+ /* 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,
+ &sam_pol) : False;
+
+ /* connect to the domain */
+ res = res ? samr_open_domain(smb_cli, fnum,
+ &sam_pol, 0x304, &sid,
+ &pol_dom) : False;
+
+ /* look up alias rid */
+ names[0] = alias_name;
+ res1 = res ? samr_query_lookup_names(smb_cli, fnum,
+ &pol_dom, 0x3e8,
+ 1, names,
+ &num_rids, rid, type) : False;
+
+ if (res1 && num_rids == 1)
+ {
+ res1 = query_aliasinfo(smb_cli, fnum,
+ &pol_dom,
+ domain,
+ &sid,
+ rid[0],
+ sam_display_alias_info);
+ }
+
+ res = res ? samr_close(smb_cli, fnum,
+ &sam_pol) : False;
+
+ res = res ? samr_close(smb_cli, fnum,
+ &pol_dom) : False;
+
+ /* close the session */
+ cli_nt_session_close(smb_cli, fnum);
+
+ if (res1)
+ {
+ DEBUG(5,("cmd_sam_query_alias: succeeded\n"));
+ }
+ else
+ {
+ DEBUG(5,("cmd_sam_query_alias: failed\n"));
+ }
+}
+
+
+/****************************************************************************
SAM aliases query.
****************************************************************************/
void cmd_sam_enum_aliases(struct client_info *info)