From b906a9df75b6bdc6fe166e9aa5a8aa398176a518 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 26 Feb 2003 00:52:41 +0000 Subject: Merge from appliance: >Another hopeful fix for CR#1168. Change the RPC used in querying >domain users from QueryDispInfo to EnumDomainUsers. Hopefully this >will fix the random dropouts that keep occuring when listing large >domains. > >My thought is that since QueryDispInfo is only used in the NT user >manager it may have a bug with large domains. A more commonly used >RPC may not have such problems. (This used to be commit 0501b7d0b12fa8063ffe6a9d4ecc3391d0c2f45d) --- source3/nsswitch/winbindd_rpc.c | 57 +++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 34 deletions(-) (limited to 'source3') diff --git a/source3/nsswitch/winbindd_rpc.c b/source3/nsswitch/winbindd_rpc.c index 48f528f520..90d8e4f616 100644 --- a/source3/nsswitch/winbindd_rpc.c +++ b/source3/nsswitch/winbindd_rpc.c @@ -3,7 +3,7 @@ Winbind rpc backend functions - Copyright (C) Tim Potter 2000-2001 + Copyright (C) Tim Potter 2000-2001,2003 Copyright (C) Andrew Tridgell 2001 This program is free software; you can redistribute it and/or modify @@ -39,18 +39,17 @@ static NTSTATUS query_user_list(struct winbindd_domain *domain, POLICY_HND dom_pol; BOOL got_dom_pol = False; uint32 des_access = SEC_RIGHTS_MAXIMUM_ALLOWED; - int i, loop_count = 0; - int retry; + int i, start_idx, retry; DEBUG(3,("rpc: query_user_list\n")); *num_entries = 0; *info = NULL; - /* Get sam handle */ - retry = 0; do { + /* Get sam handle */ + if (!(hnd = cm_get_sam_handle(domain->name))) goto done; @@ -66,50 +65,39 @@ static NTSTATUS query_user_list(struct winbindd_domain *domain, got_dom_pol = True; - i = 0; + i = start_idx = 0; do { - SAM_DISPINFO_CTR ctr; - SAM_DISPINFO_1 info1; - uint32 count = 0, start=i, max_entries, max_size; - int j; TALLOC_CTX *ctx2; + char **dom_users; + uint32 num_dom_users, *dom_rids, j, size = 0xffff; + uint16 acb_mask = ACB_NORMAL; - ctr.sam.info1 = &info1; - - ctx2 = talloc_init("winbindd dispinfo"); - if (!ctx2) { + if (!(ctx2 = talloc_init("winbindd enum_users"))) { result = NT_STATUS_NO_MEMORY; goto done; - } - - get_query_dispinfo_params( - loop_count, &max_entries, &max_size); - - /* Query display info level 1 */ - result = cli_samr_query_dispinfo( - hnd->cli, ctx2, &dom_pol, &start, 1, &count, - max_entries, max_size, &ctr); + } - loop_count++; + result = cli_samr_enum_dom_users( + hnd->cli, ctx2, &dom_pol, &start_idx, acb_mask, + size, &dom_users, &dom_rids, &num_dom_users); - if (!NT_STATUS_IS_OK(result) && - !NT_STATUS_EQUAL(result, STATUS_MORE_ENTRIES)) break; + *num_entries += num_dom_users; - (*num_entries) += count; + *info = talloc_realloc( + mem_ctx, *info, + (*num_entries) * sizeof(WINBIND_USERINFO)); - /* now map the result into the WINBIND_USERINFO structure */ - (*info) = talloc_realloc(mem_ctx, *info, - (*num_entries)*sizeof(WINBIND_USERINFO)); if (!(*info)) { result = NT_STATUS_NO_MEMORY; talloc_destroy(ctx2); goto done; } - for (j=0;j