diff options
author | Volker Lendecke <vl@samba.org> | 2017-01-03 12:11:30 +0000 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2017-01-04 12:22:13 +0100 |
commit | 480c9581a13afc08b20e80d2ff8a45ac8d7f18d3 (patch) | |
tree | 17622f4d2e38895e16de4de985a8514ba949e217 /source3/winbindd/winbindd_rpc.c | |
parent | 67c0696761dedb748b1e4dc02531acbbf5ff95ca (diff) | |
download | samba-480c9581a13afc08b20e80d2ff8a45ac8d7f18d3.tar.gz |
winbind: Simplify query_user_list to only return rids
Unfortunately this is a pretty large patch, because many functions
implement this API. The alternative would have been to create a new
backend function, add the new one piece by piece and then remove the
original function.
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Uri Simchoni <uri@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'source3/winbindd/winbindd_rpc.c')
-rw-r--r-- | source3/winbindd/winbindd_rpc.c | 62 |
1 files changed, 11 insertions, 51 deletions
diff --git a/source3/winbindd/winbindd_rpc.c b/source3/winbindd/winbindd_rpc.c index 1e234ba4181..bb8af45c896 100644 --- a/source3/winbindd/winbindd_rpc.c +++ b/source3/winbindd/winbindd_rpc.c @@ -38,18 +38,17 @@ NTSTATUS rpc_query_user_list(TALLOC_CTX *mem_ctx, struct rpc_pipe_client *samr_pipe, struct policy_handle *samr_policy, const struct dom_sid *domain_sid, - uint32_t *pnum_info, - struct wbint_userinfo **pinfo) + uint32_t **prids) { - struct wbint_userinfo *info = NULL; - uint32_t num_info = 0; + uint32_t *rids = NULL; + uint32_t num_rids = 0; uint32_t loop_count = 0; uint32_t start_idx = 0; uint32_t i = 0; NTSTATUS status, result; struct dcerpc_binding_handle *b = samr_pipe->binding_handle; - *pnum_info = 0; + *prids = NULL; do { uint32_t j; @@ -87,62 +86,23 @@ NTSTATUS rpc_query_user_list(TALLOC_CTX *mem_ctx, loop_count++; num_dom_users = disp_info.info1.count; - num_info += num_dom_users; + num_rids += num_dom_users; /* If there are no user to enumerate we're done */ - if (num_info == 0) { + if (num_rids == 0) { return NT_STATUS_OK; } - info = talloc_realloc(mem_ctx, - info, - struct wbint_userinfo, - num_info); - if (info == NULL) { + rids = talloc_realloc(mem_ctx, rids, uint32_t, num_rids); + if (rids == NULL) { return NT_STATUS_NO_MEMORY; } - for (j = 0; j < num_dom_users; i++, j++) { - uint32_t rid = disp_info.info1.entries[j].rid; - struct samr_DispEntryGeneral *src; - struct wbint_userinfo *dst; - - src = &(disp_info.info1.entries[j]); - dst = &(info[i]); - - *dst = (struct wbint_userinfo) {0}; - - dst->acct_name = talloc_strdup(info, - src->account_name.string); - if (dst->acct_name == NULL) { - return NT_STATUS_NO_MEMORY; - } - - dst->full_name = talloc_strdup(info, src->full_name.string); - if ((src->full_name.string != NULL) && - (dst->full_name == NULL)) - { - return NT_STATUS_NO_MEMORY; - } - - dst->homedir = NULL; - dst->shell = NULL; - dst->primary_gid = (gid_t)-1; - sid_compose(&dst->user_sid, domain_sid, rid); - - /* For the moment we set the primary group for - every user to be the Domain Users group. - There are serious problems with determining - the actual primary group for large domains. - This should really be made into a 'winbind - force group' smb.conf parameter or - something like that. */ - sid_compose(&dst->group_sid, domain_sid, - DOMAIN_RID_USERS); + for (j = 0; j < num_dom_users; j++) { + rids[i++] = disp_info.info1.entries[j].rid; } } while (NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)); - *pnum_info = num_info; - *pinfo = info; + *prids = rids; return NT_STATUS_OK; } |