summaryrefslogtreecommitdiff
path: root/source3/rpcclient
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>1999-10-29 17:37:27 +0000
committerLuke Leighton <lkcl@samba.org>1999-10-29 17:37:27 +0000
commitd0fd259514a4cc4e7ec2b021ff68fe0e3fd1bf09 (patch)
treedca98444b7486e868d0174e4888859a853ff2abf /source3/rpcclient
parent3d096e1b8f5a253b61cbfa6155b0a16a5394c847 (diff)
downloadsamba-d0fd259514a4cc4e7ec2b021ff68fe0e3fd1bf09.tar.gz
samba-d0fd259514a4cc4e7ec2b021ff68fe0e3fd1bf09.tar.bz2
samba-d0fd259514a4cc4e7ec2b021ff68fe0e3fd1bf09.zip
more reshuffling of enum groups code. more higher order functions.
(This used to be commit 497d4231723576390b10f5ea8704bd0af88d76ab)
Diffstat (limited to 'source3/rpcclient')
-rw-r--r--source3/rpcclient/cmd_samr.c88
-rw-r--r--source3/rpcclient/display.c83
2 files changed, 135 insertions, 36 deletions
diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c
index c2132aff63..9d80c4fa53 100644
--- a/source3/rpcclient/cmd_samr.c
+++ b/source3/rpcclient/cmd_samr.c
@@ -1220,25 +1220,6 @@ static void req_user_info(struct cli_state *cli, uint16 fnum,
}
}
-static void query_groupinfo(struct cli_state *cli, uint16 fnum,
- POLICY_HND *pol_dom,
- uint32 group_rid)
-{
- GROUP_INFO_CTR ctr;
-
- /* send group info query */
- if (get_samr_query_groupinfo(smb_cli, fnum,
- pol_dom,
- 1, group_rid, &ctr))
- {
-#if 0
- display_samr_groupinfo(out_hnd, ACTION_HEADER , &ctr);
- display_samr_groupinfo(out_hnd, ACTION_ENUMERATE, &ctr);
- display_samr_groupinfo(out_hnd, ACTION_FOOTER , &ctr);
-#endif
- }
-}
-
/****************************************************************************
SAM Query User Groups.
****************************************************************************/
@@ -2098,15 +2079,48 @@ BOOL sam_query_groupmem(struct cli_state *cli, uint16 fnum,
return res3;
}
-static void sam_display_group_members(uint32 group_rid, char *group_name,
+static void sam_display_group_info(char *domain, DOM_SID *sid,
+ uint32 group_rid,
+ GROUP_INFO_CTR *ctr)
+{
+ display_group_info_ctr(out_hnd, ACTION_HEADER , ctr);
+ display_group_info_ctr(out_hnd, ACTION_ENUMERATE, ctr);
+ display_group_info_ctr(out_hnd, ACTION_FOOTER , ctr);
+}
+
+static void query_groupinfo(struct cli_state *cli, uint16 fnum,
+ POLICY_HND *pol_dom,
+ char *domain,
+ DOM_SID *sid,
+ uint32 group_rid,
+ void (*grp_inf)(char*, DOM_SID*, uint32, GROUP_INFO_CTR *))
+{
+ GROUP_INFO_CTR ctr;
+
+ /* send group info query */
+ if (get_samr_query_groupinfo(smb_cli, fnum,
+ pol_dom,
+ 1, /* info level */
+ group_rid, &ctr))
+ {
+ grp_inf(domain, sid, group_rid, &ctr);
+ }
+}
+
+static void sam_display_group(char *domain, DOM_SID *sid,
+ uint32 group_rid, char *group_name)
+{
+ report(out_hnd, "Group RID: %8x Group Name: %s\n",
+ group_rid, group_name);
+}
+
+static void sam_display_group_members(char *domain, DOM_SID *sid,
+ uint32 group_rid, char *group_name,
uint32 num_names,
uint32 *rid_mem,
char **name,
uint32 *type)
{
- report(out_hnd, "Group RID: %8x Group Name: %s\n",
- group_rid, group_name);
-
display_group_members(out_hnd, ACTION_HEADER , num_names, name, type);
display_group_members(out_hnd, ACTION_ENUMERATE, num_names, name, type);
display_group_members(out_hnd, ACTION_FOOTER , num_names, name, type);
@@ -2114,9 +2128,11 @@ static void sam_display_group_members(uint32 group_rid, char *group_name,
static void req_groupmem_info(struct cli_state *cli, uint16 fnum,
POLICY_HND *pol_dom,
+ char *domain,
+ DOM_SID *sid,
uint32 group_rid,
char *group_name,
- void(*act_fn)(uint32, char*, uint32, uint32*, char**, uint32*))
+ void(*act_fn)(char*, DOM_SID*, uint32, char*, uint32, uint32*, char**, uint32*))
{
uint32 num_names = 0;
char **name = NULL;
@@ -2127,7 +2143,9 @@ static void req_groupmem_info(struct cli_state *cli, uint16 fnum,
&num_names, &rid_mem, &name, &type))
{
- act_fn(group_rid, group_name, num_names, rid_mem, name, type);
+ act_fn(domain, sid,
+ group_rid, group_name,
+ num_names, rid_mem, name, type);
free_char_array(num_names, name);
if (type != NULL)
@@ -2143,8 +2161,9 @@ SAM groups query.
uint32 msrpc_sam_enum_groups(struct client_info *info,
struct acct_info **sam,
uint32 *num_sam_entries,
- void(*grp_mem_fn)(uint32, char*, uint32, uint32*, char**, uint32*),
- BOOL request_group_info)
+ void (*grp_fn)(char*, DOM_SID*, uint32, char*),
+ void (*grp_inf_fn)(char*, DOM_SID*, uint32, GROUP_INFO_CTR *),
+ void(*grp_mem_fn)(char*, DOM_SID*, uint32, char*, uint32, uint32*, char**, uint32*))
{
uint16 fnum;
fstring srv_name;
@@ -2215,13 +2234,19 @@ uint32 msrpc_sam_enum_groups(struct client_info *info,
uint32 group_rid = (*sam)[group_idx].rid;
char *group_name = (*sam)[group_idx].acct_name;
- if (request_group_info)
+ grp_fn(domain, &sid1, group_rid, group_name);
+
+ if (grp_inf_fn)
{
- query_groupinfo(smb_cli, fnum, &pol_dom, group_rid);
+ query_groupinfo(smb_cli, fnum, &pol_dom,
+ domain, &sid1,
+ group_rid,
+ grp_inf_fn);
}
if (grp_mem_fn != NULL)
{
req_groupmem_info(smb_cli, fnum, &pol_dom,
+ domain, &sid1,
group_rid, group_name,
grp_mem_fn);
}
@@ -2275,8 +2300,9 @@ void cmd_sam_enum_groups(struct client_info *info)
}
msrpc_sam_enum_groups(info, &sam, &num_sam_entries,
- request_group_info ? sam_display_group_members : NULL,
- request_member_info);
+ sam_display_group,
+ request_group_info ? sam_display_group_info : NULL,
+ request_member_info ? sam_display_group_members : NULL);
if (sam != NULL)
{
diff --git a/source3/rpcclient/display.c b/source3/rpcclient/display.c
index 9b8a8154f3..db5208b33c 100644
--- a/source3/rpcclient/display.c
+++ b/source3/rpcclient/display.c
@@ -1215,8 +1215,6 @@ void display_group_members(FILE *out_hnd, enum action_type action,
}
-#if 0
-
/****************************************************************************
display group info
****************************************************************************/
@@ -1231,9 +1229,85 @@ void display_group_info1(FILE *out_hnd, enum action_type action, GROUP_INFO1 *in
}
case ACTION_ENUMERATE:
{
- int i;
+ fstring temp;
+
+ unistr2_to_ascii(temp, &info1->uni_acct_name, sizeof(temp)-1);
+ fprintf(out_hnd, "\tGroup Name:\t%s\n", temp);
+ unistr2_to_ascii(temp, &info1->uni_acct_desc, sizeof(temp)-1);
+ fprintf(out_hnd, "\tDescription:\t%s\n", temp);
+ fprintf(out_hnd, "\tunk1:%d\n", info1->unknown_1);
+ fprintf(out_hnd, "\tNum Members:%d\n", info1->num_members);
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+ display group info
+ ****************************************************************************/
+void display_group_info4(FILE *out_hnd, enum action_type action, GROUP_INFO4 *info4)
+
+{
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ fstring desc;
+
+ unistr2_to_ascii(desc, &info4->uni_acct_desc, sizeof(desc)-1);
+ fprintf(out_hnd, "\tGroup Description:%s\n",
+ desc);
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+ display sam sync structure
+ ****************************************************************************/
+void display_group_info_ctr(FILE *out_hnd, enum action_type action,
+ GROUP_INFO_CTR *ctr)
+{
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ fprintf(out_hnd, "\tSAM Group Info\n");
+ fprintf(out_hnd, "\t--------------\n");
- fprintf(out_hnd, "\tGroup Name:\t%s\tDescription:\t%s\tunk1:\t%sunk2:%s\n",
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ switch (ctr->switch_value1)
+ {
+ case 1:
+ {
+ display_group_info1(out_hnd, ACTION_HEADER , &ctr->group.info1);
+ display_group_info1(out_hnd, ACTION_ENUMERATE, &ctr->group.info1);
+ display_group_info1(out_hnd, ACTION_FOOTER , &ctr->group.info1);
+ break;
+ }
+ case 4:
+ {
+ display_group_info4(out_hnd, ACTION_HEADER , &ctr->group.info4);
+ display_group_info4(out_hnd, ACTION_ENUMERATE, &ctr->group.info4);
+ display_group_info4(out_hnd, ACTION_FOOTER , &ctr->group.info4);
+ break;
+ }
+ }
break;
}
case ACTION_FOOTER:
@@ -1243,7 +1317,6 @@ void display_group_info1(FILE *out_hnd, enum action_type action, GROUP_INFO1 *in
}
}
}
-#endif
/****************************************************************************
display group rid info