diff options
author | Luke Leighton <lkcl@samba.org> | 1999-10-29 17:37:27 +0000 |
---|---|---|
committer | Luke Leighton <lkcl@samba.org> | 1999-10-29 17:37:27 +0000 |
commit | d0fd259514a4cc4e7ec2b021ff68fe0e3fd1bf09 (patch) | |
tree | dca98444b7486e868d0174e4888859a853ff2abf /source3 | |
parent | 3d096e1b8f5a253b61cbfa6155b0a16a5394c847 (diff) | |
download | samba-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')
-rw-r--r-- | source3/include/proto.h | 11 | ||||
-rw-r--r-- | source3/include/rpc_samr.h | 2 | ||||
-rw-r--r-- | source3/rpc_client/cli_samr.c | 2 | ||||
-rw-r--r-- | source3/rpc_parse/parse_samr.c | 7 | ||||
-rw-r--r-- | source3/rpc_server/srv_samr.c | 8 | ||||
-rw-r--r-- | source3/rpcclient/cmd_samr.c | 88 | ||||
-rw-r--r-- | source3/rpcclient/display.c | 83 |
7 files changed, 153 insertions, 48 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index 74d81ad7f1..82984e8f92 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -2551,7 +2551,8 @@ BOOL make_samr_q_open_group(SAMR_Q_OPEN_GROUP *q_c, BOOL samr_io_q_open_group(char *desc, SAMR_Q_OPEN_GROUP *q_u, prs_struct *ps, int depth); BOOL samr_io_r_open_group(char *desc, SAMR_R_OPEN_GROUP *r_u, prs_struct *ps, int depth); BOOL make_samr_group_info1(GROUP_INFO1 *gr1, - char *acct_name, char *acct_desc); + char *acct_name, char *acct_desc, + uint32 num_members); BOOL samr_io_group_info1(char *desc, GROUP_INFO1 *gr1, prs_struct *ps, int depth); BOOL make_samr_group_info4(GROUP_INFO4 *gr4, const char *acct_desc); BOOL samr_io_group_info4(char *desc, GROUP_INFO4 *gr4, prs_struct *ps, int depth); @@ -3251,8 +3252,9 @@ BOOL sam_query_groupmem(struct cli_state *cli, uint16 fnum, 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*)); void cmd_sam_enum_groups(struct client_info *info); /*The following definitions come from rpcclient/cmd_srvsvc.c */ @@ -3340,6 +3342,9 @@ void display_alias_rid_info(FILE *out_hnd, enum action_type action, void display_group_members(FILE *out_hnd, enum action_type action, uint32 num_mem, char **name, uint32 *type); void display_group_info1(FILE *out_hnd, enum action_type action, GROUP_INFO1 *info1); +void display_group_info4(FILE *out_hnd, enum action_type action, GROUP_INFO4 *info4); +void display_group_info_ctr(FILE *out_hnd, enum action_type action, + GROUP_INFO_CTR *ctr); void display_group_rid_info(FILE *out_hnd, enum action_type action, uint32 num_gids, DOM_GID *gid); void display_alias_name_info(FILE *out_hnd, enum action_type action, diff --git a/source3/include/rpc_samr.h b/source3/include/rpc_samr.h index afe104a93a..87fc17cda9 100644 --- a/source3/include/rpc_samr.h +++ b/source3/include/rpc_samr.h @@ -944,7 +944,7 @@ typedef struct samr_group_info1 UNIHDR hdr_acct_name; uint32 unknown_1; /* 0x0000 0003 - number of group members? */ - uint32 unknown_2; /* 0x0000 0001 - number of group members? */ + uint32 num_members; /* 0x0000 0001 - number of group members? */ UNIHDR hdr_acct_desc; diff --git a/source3/rpc_client/cli_samr.c b/source3/rpc_client/cli_samr.c index 41bdd0e3d1..ccf76eb943 100644 --- a/source3/rpc_client/cli_samr.c +++ b/source3/rpc_client/cli_samr.c @@ -358,7 +358,7 @@ BOOL get_samr_query_groupinfo(struct cli_state *cli, uint16 fnum, /* send open domain (on group sid) */ if (!samr_open_group(cli, fnum, pol_open_domain, - 0x00000010, group_rid, &pol_open_group)) + 0x02000000, group_rid, &pol_open_group)) { return False; } diff --git a/source3/rpc_parse/parse_samr.c b/source3/rpc_parse/parse_samr.c index e111484676..74386e7f99 100644 --- a/source3/rpc_parse/parse_samr.c +++ b/source3/rpc_parse/parse_samr.c @@ -1904,7 +1904,8 @@ BOOL samr_io_r_open_group(char *desc, SAMR_R_OPEN_GROUP *r_u, prs_struct *ps, i makes a GROUP_INFO1 structure. ********************************************************************/ BOOL make_samr_group_info1(GROUP_INFO1 *gr1, - char *acct_name, char *acct_desc) + char *acct_name, char *acct_desc, + uint32 num_members) { int desc_len = acct_desc != NULL ? strlen(acct_desc) : 0; int acct_len = acct_name != NULL ? strlen(acct_name) : 0; @@ -1915,7 +1916,7 @@ BOOL make_samr_group_info1(GROUP_INFO1 *gr1, make_uni_hdr(&(gr1->hdr_acct_name), acct_len); gr1->unknown_1 = 0x3; - gr1->unknown_2 = 0x3; + gr1->num_members = num_members; make_uni_hdr(&(gr1->hdr_acct_desc), desc_len); @@ -1941,7 +1942,7 @@ BOOL samr_io_group_info1(char *desc, GROUP_INFO1 *gr1, prs_struct *ps, int dept smb_io_unihdr ("hdr_acct_name", &(gr1->hdr_acct_name) , ps, depth); prs_uint32("unknown_1", ps, depth, &(gr1->unknown_1)); - prs_uint32("unknown_2", ps, depth, &(gr1->unknown_2)); + prs_uint32("num_members", ps, depth, &(gr1->num_members)); smb_io_unihdr ("hdr_acct_desc", &(gr1->hdr_acct_desc) , ps, depth); diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c index bfbeb5718c..7af69a2eb4 100644 --- a/source3/rpc_server/srv_samr.c +++ b/source3/rpc_server/srv_samr.c @@ -1136,15 +1136,15 @@ static void samr_reply_query_groupinfo(SAMR_Q_QUERY_GROUPINFO *q_u, r_e.ptr = 1; ctr.switch_value1 = 1; make_samr_group_info1(&ctr.group.info1, - "account name", - "account description"); + "fake account name", + "fake account description", 2); } else if (q_u->switch_level == 4) { r_e.ptr = 1; ctr.switch_value1 = 4; make_samr_group_info4(&ctr.group.info4, - "account description"); + "fake account description"); } else { @@ -1198,7 +1198,7 @@ static void samr_reply_query_aliasinfo(SAMR_Q_QUERY_ALIASINFO *q_u, { r_e.ptr = 1; ctr.switch_value1 = 3; - make_samr_alias_info3(&ctr.alias.info3, "<account description>"); + make_samr_alias_info3(&ctr.alias.info3, "<fake account description>"); } else { 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 |