summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>1999-10-29 16:19:17 +0000
committerLuke Leighton <lkcl@samba.org>1999-10-29 16:19:17 +0000
commit97993e4973333b504abd2de7a23b1a554841d547 (patch)
tree5a501a013acde7ce5292cca686ec8fbc57781333
parent902b53dcc0933045980ed5d7df4959eee6f016d3 (diff)
downloadsamba-97993e4973333b504abd2de7a23b1a554841d547.tar.gz
samba-97993e4973333b504abd2de7a23b1a554841d547.tar.bz2
samba-97993e4973333b504abd2de7a23b1a554841d547.zip
using higher-order-function in enum groups as a test. makes it really
useful for doing things _other_ than just "print me". (This used to be commit 229313de7dc734a6c77e9000e654b0c289053fa6)
-rw-r--r--source3/rpcclient/cmd_samr.c40
1 files changed, 27 insertions, 13 deletions
diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c
index f0ce84e3ef..c2132aff63 100644
--- a/source3/rpcclient/cmd_samr.c
+++ b/source3/rpcclient/cmd_samr.c
@@ -2098,9 +2098,25 @@ BOOL sam_query_groupmem(struct cli_state *cli, uint16 fnum,
return res3;
}
+static void sam_display_group_members(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);
+}
+
static void req_groupmem_info(struct cli_state *cli, uint16 fnum,
POLICY_HND *pol_dom,
- uint32 group_rid)
+ uint32 group_rid,
+ char *group_name,
+ void(*act_fn)(uint32, char*, uint32, uint32*, char**, uint32*))
{
uint32 num_names = 0;
char **name = NULL;
@@ -2110,9 +2126,8 @@ static void req_groupmem_info(struct cli_state *cli, uint16 fnum,
if (sam_query_groupmem(cli, fnum, pol_dom, group_rid,
&num_names, &rid_mem, &name, &type))
{
- 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);
+
+ act_fn(group_rid, group_name, num_names, rid_mem, name, type);
free_char_array(num_names, name);
if (type != NULL)
@@ -2128,7 +2143,7 @@ SAM groups query.
uint32 msrpc_sam_enum_groups(struct client_info *info,
struct acct_info **sam,
uint32 *num_sam_entries,
- BOOL request_member_info,
+ void(*grp_mem_fn)(uint32, char*, uint32, uint32*, char**, uint32*),
BOOL request_group_info)
{
uint16 fnum;
@@ -2198,18 +2213,17 @@ uint32 msrpc_sam_enum_groups(struct client_info *info,
for (group_idx = 0; group_idx < (*num_sam_entries); group_idx++)
{
uint32 group_rid = (*sam)[group_idx].rid;
-
- report(out_hnd, "Group RID: %8x Group Name: %s\n",
- group_rid,
- (*sam)[group_idx].acct_name);
+ char *group_name = (*sam)[group_idx].acct_name;
if (request_group_info)
{
query_groupinfo(smb_cli, fnum, &pol_dom, group_rid);
}
- if (request_member_info)
+ if (grp_mem_fn != NULL)
{
- req_groupmem_info(smb_cli, fnum, &pol_dom, group_rid);
+ req_groupmem_info(smb_cli, fnum, &pol_dom,
+ group_rid, group_name,
+ grp_mem_fn);
}
}
}
@@ -2261,8 +2275,8 @@ void cmd_sam_enum_groups(struct client_info *info)
}
msrpc_sam_enum_groups(info, &sam, &num_sam_entries,
- request_member_info,
- request_group_info);
+ request_group_info ? sam_display_group_members : NULL,
+ request_member_info);
if (sam != NULL)
{