diff options
author | Luke Leighton <lkcl@samba.org> | 1999-10-26 20:03:48 +0000 |
---|---|---|
committer | Luke Leighton <lkcl@samba.org> | 1999-10-26 20:03:48 +0000 |
commit | 1298a3d1e0f7fc40b2bcb22f2e9674d01d00ae60 (patch) | |
tree | a1678fe53d4123f14655de2339975a39579466de | |
parent | ea6592046f40ca21c689bff6472b4dd764850e43 (diff) | |
download | samba-1298a3d1e0f7fc40b2bcb22f2e9674d01d00ae60.tar.gz samba-1298a3d1e0f7fc40b2bcb22f2e9674d01d00ae60.tar.bz2 samba-1298a3d1e0f7fc40b2bcb22f2e9674d01d00ae60.zip |
created samr_query_groupmem() function from existing code.
(This used to be commit d2d5a853f8f34a0c3d5920540beb971a33f5276e)
-rw-r--r-- | source3/include/proto.h | 6 | ||||
-rw-r--r-- | source3/rpcclient/cmd_samr.c | 97 |
2 files changed, 79 insertions, 24 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index 6789fdd0be..a4beb01de6 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -3226,6 +3226,12 @@ BOOL sam_query_dominfo(struct client_info *info, DOM_SID *sid1, uint32 switch_value, SAM_UNK_CTR *ctr); void cmd_sam_query_dominfo(struct client_info *info); void cmd_sam_enum_aliases(struct client_info *info); +BOOL sam_query_groupmem(struct client_info *info, uint16 fnum, + uint32 group_rid, + uint32 *num_names, + uint32 **rid_mem, + char ***name, + uint32 **type); void cmd_sam_enum_groups(struct client_info *info); /*The following definitions come from rpcclient/cmd_srvsvc.c */ diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c index 7d59503de4..438760243d 100644 --- a/source3/rpcclient/cmd_samr.c +++ b/source3/rpcclient/cmd_samr.c @@ -1426,10 +1426,9 @@ int msrpc_sam_enum_users(struct client_info *info, { status = samr_enum_dom_users(smb_cli, fnum, &info->dom.samr_pol_open_domain, - &start_idx, acb_mask, unk_1, 0x01, + &start_idx, acb_mask, unk_1, 0x10000, &info->dom.sam, &info->dom.num_sam_entries); } - if (info->dom.num_sam_entries == 0) { @@ -1979,48 +1978,98 @@ void cmd_sam_enum_aliases(struct client_info *info) } } -static void req_groupmem_info(struct client_info *info, uint16 fnum, - uint32 group_rid) +BOOL sam_query_groupmem(struct client_info *info, uint16 fnum, + uint32 group_rid, + uint32 *num_names, + uint32 **rid_mem, + char ***name, + uint32 **type) { uint32 num_mem; - uint32 *rid_mem = NULL; uint32 *attr_mem = NULL; + BOOL res3; + + *rid_mem = NULL; + *num_names = 0; + *name = NULL; + *type = NULL; /* get group members */ - if (get_samr_query_groupmem(smb_cli, fnum, + res3 = get_samr_query_groupmem(smb_cli, fnum, &info->dom.samr_pol_open_domain, - group_rid, &num_mem, &rid_mem, &attr_mem)) + group_rid, &num_mem, rid_mem, &attr_mem); + + if (res3 && num_mem != 0) { - BOOL res3 = True; - uint32 num_names = 0; - char **name = NULL; - uint32 *type = NULL; + uint32 *rid_copy = (uint32*)malloc(num_mem * sizeof(*rid_copy)); - res3 = samr_query_lookup_rids(smb_cli, fnum, + if (rid_copy != NULL) + { + int i; + for (i = 0; i < num_mem; i++) + { + rid_copy[i] = (*rid_mem)[i]; + } + /* resolve names */ + res3 = samr_query_lookup_rids(smb_cli, fnum, &info->dom.samr_pol_open_domain, 1000, - num_mem, rid_mem, &num_names, &name, &type); - - if (res3) + num_mem, rid_copy, num_names, name, type); + } + } + else + { + if (attr_mem != NULL) { - 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); + free(attr_mem); } + if ((*rid_mem) != NULL) + { + free(*rid_mem); + } + attr_mem = NULL; + *rid_mem = NULL; + } - free_char_array(num_names, name); - if (type != NULL) + if (!res3) + { + free_char_array(*num_names, *name); + if ((*type) != NULL) { - free(type); + free(*type); } + *num_names = 0; + *name = NULL; + *type = NULL; } if (attr_mem != NULL) { free(attr_mem); } - if (rid_mem != NULL) + + return res3; +} + +static void req_groupmem_info(struct client_info *info, uint16 fnum, + uint32 group_rid) +{ + uint32 num_names = 0; + char **name = NULL; + uint32 *type = NULL; + uint32 *rid_mem = NULL; + + if (sam_query_groupmem(info, fnum, group_rid, + &num_names, &rid_mem, &name, &type)) { - free(rid_mem); + 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); + + free_char_array(num_names, name); + if (type != NULL) + { + free(type); + } } } @@ -2094,7 +2143,7 @@ void cmd_sam_enum_groups(struct client_info *info) /* read some groups */ res = res ? samr_enum_dom_groups(smb_cli, fnum, &info->dom.samr_pol_open_domain, - 0x0, 0x03, + 0x0, 0x100000, &info->dom.sam, &info->dom.num_sam_entries) : False; if (res && info->dom.num_sam_entries == 0) |