r25247: Rename the rpccli_lsa_lookup_sids_all() function to rpccli_lsa_lookup_sids()
authorMichael Adam <obnox@samba.org>
Wed, 19 Sep 2007 22:11:09 +0000 (22:11 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:30:54 +0000 (12:30 -0500)
and remove the old rpccli_lsa_lookup_sids() function. The old function would
fail due to server limits when requesting to resolve too many sids at once
(20480 for W2k3). The new version passes the list of sids in hunks to the
server. It has up to now been used (and tested) in the winbindd_ads
lookup_groupmem() function, and I think the time has come to replace the actual
function with this correct version.

Michael

source/rpc_client/cli_lsarpc.c
source/winbindd/winbindd_ads.c

index 0f66f1428873a20040ef179d0318d27d337ca087..1af31228da0e89382c1703447be3cbb233e17981 100644 (file)
@@ -244,14 +244,14 @@ done:
  * at 20480 for win2k3, but we keep it at a save 1000 for now. */
 #define LOOKUP_SIDS_HUNK_SIZE 1000
 
-NTSTATUS rpccli_lsa_lookup_sids_all(struct rpc_pipe_client *cli,
-                                   TALLOC_CTX *mem_ctx,
-                                   POLICY_HND *pol,
-                                   int num_sids,
-                                   const DOM_SID *sids,
-                                   char ***domains,
-                                   char ***names,
-                                   enum lsa_SidType **types)
+NTSTATUS rpccli_lsa_lookup_sids(struct rpc_pipe_client *cli,
+                               TALLOC_CTX *mem_ctx,
+                               POLICY_HND *pol,
+                               int num_sids,
+                               const DOM_SID *sids,
+                               char ***domains,
+                               char ***names,
+                               enum lsa_SidType **types)
 {
        NTSTATUS result = NT_STATUS_OK;
        int sids_left = 0;
@@ -263,19 +263,19 @@ NTSTATUS rpccli_lsa_lookup_sids_all(struct rpc_pipe_client *cli,
 
        if (num_sids) {
                if (!((*domains) = TALLOC_ARRAY(mem_ctx, char *, num_sids))) {
-                       DEBUG(0, ("rpccli_lsa_lookup_sids_all(): out of memory\n"));
+                       DEBUG(0, ("rpccli_lsa_lookup_sids(): out of memory\n"));
                        result = NT_STATUS_NO_MEMORY;
                        goto fail;
                }
 
                if (!((*names) = TALLOC_ARRAY(mem_ctx, char *, num_sids))) {
-                       DEBUG(0, ("rpccli_lsa_lookup_sids_all(): out of memory\n"));
+                       DEBUG(0, ("rpccli_lsa_lookup_sids(): out of memory\n"));
                        result = NT_STATUS_NO_MEMORY;
                        goto fail;
                }
 
                if (!((*types) = TALLOC_ARRAY(mem_ctx, enum lsa_SidType, num_sids))) {
-                       DEBUG(0, ("rpccli_lsa_lookup_sids_all(): out of memory\n"));
+                       DEBUG(0, ("rpccli_lsa_lookup_sids(): out of memory\n"));
                        result = NT_STATUS_NO_MEMORY;
                        goto fail;
                }
@@ -298,7 +298,7 @@ NTSTATUS rpccli_lsa_lookup_sids_all(struct rpc_pipe_client *cli,
                                ? LOOKUP_SIDS_HUNK_SIZE
                                : sids_left);
 
-               DEBUG(10, ("rpccli_lsa_lookup_sids_all: processing items "
+               DEBUG(10, ("rpccli_lsa_lookup_sids: processing items "
                           "%d -- %d of %d.\n",
                           sids_processed,
                           sids_processed + hunk_num_sids - 1,
@@ -349,114 +349,6 @@ fail:
        return result;
 }
 
-/** Lookup a list of sids */
-
-NTSTATUS rpccli_lsa_lookup_sids(struct rpc_pipe_client *cli,
-                               TALLOC_CTX *mem_ctx,
-                               POLICY_HND *pol, int num_sids,
-                               const DOM_SID *sids,
-                               char ***domains,
-                               char ***names,
-                               enum lsa_SidType **types)
-{
-       prs_struct qbuf, rbuf;
-       LSA_Q_LOOKUP_SIDS q;
-       LSA_R_LOOKUP_SIDS r;
-       DOM_R_REF ref;
-       NTSTATUS result = NT_STATUS_OK;
-       int i;
-
-       ZERO_STRUCT(q);
-       ZERO_STRUCT(r);
-
-       init_q_lookup_sids(mem_ctx, &q, pol, num_sids, sids, 1);
-
-       ZERO_STRUCT(ref);
-
-       r.dom_ref = &ref;
-
-       CLI_DO_RPC( cli, mem_ctx, PI_LSARPC, LSA_LOOKUPSIDS,
-                       q, r,
-                       qbuf, rbuf,
-                       lsa_io_q_lookup_sids,
-                       lsa_io_r_lookup_sids,
-                       NT_STATUS_UNSUCCESSFUL );
-
-       if (!NT_STATUS_IS_OK(r.status) &&
-           !NT_STATUS_EQUAL(r.status, STATUS_SOME_UNMAPPED)) {
-
-               /* An actual error occured */
-               result = r.status;
-
-               goto done;
-       }
-
-       /* Return output parameters */
-
-       if (r.mapped_count == 0) {
-               result = NT_STATUS_NONE_MAPPED;
-               goto done;
-       }
-
-       if (num_sids) {
-               if (!((*domains) = TALLOC_ARRAY(mem_ctx, char *, num_sids))) {
-                       DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
-                       result = NT_STATUS_NO_MEMORY;
-                       goto done;
-               }
-
-               if (!((*names) = TALLOC_ARRAY(mem_ctx, char *, num_sids))) {
-                       DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
-                       result = NT_STATUS_NO_MEMORY;
-                       goto done;
-               }
-
-               if (!((*types) = TALLOC_ARRAY(mem_ctx, enum lsa_SidType, num_sids))) {
-                       DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
-                       result = NT_STATUS_NO_MEMORY;
-                       goto done;
-               }
-       } else {
-               (*domains) = NULL;
-               (*names) = NULL;
-               (*types) = NULL;
-       }
-
-       for (i = 0; i < num_sids; i++) {
-               fstring name, dom_name;
-               uint32 dom_idx = r.names.name[i].domain_idx;
-
-               /* Translate optimised name through domain index array */
-
-               if (dom_idx != 0xffffffff) {
-
-                       rpcstr_pull_unistr2_fstring(
-                                dom_name, &ref.ref_dom[dom_idx].uni_dom_name);
-                       rpcstr_pull_unistr2_fstring(
-                                name, &r.names.uni_name[i]);
-
-                       (*names)[i] = talloc_strdup(mem_ctx, name);
-                       (*domains)[i] = talloc_strdup(mem_ctx, dom_name);
-                       (*types)[i] = (enum lsa_SidType)r.names.name[i].sid_name_use;
-
-                       if (((*names)[i] == NULL) || ((*domains)[i] == NULL)) {
-                               DEBUG(0, ("cli_lsa_lookup_sids(): out of memory\n"));
-                               result = NT_STATUS_UNSUCCESSFUL;
-                               goto done;
-                       }
-
-               } else {
-                       (*names)[i] = NULL;
-                       (*domains)[i] = NULL;
-                       (*types)[i] = SID_NAME_UNKNOWN;
-               }
-       }
-
- done:
-
-       return result;
-}
-
 /** Lookup a list of names */
 
 NTSTATUS rpccli_lsa_lookup_names(struct rpc_pipe_client *cli,
index 65cc00bb97d043af51f67e399f14d1a45a941e67..488967ed09a38d571dfcdc6d26c4de8d5f9e0a13 100644 (file)
@@ -1049,13 +1049,13 @@ static NTSTATUS lookup_groupmem(struct winbindd_domain *domain,
                        goto done;
                }
 
-               status = rpccli_lsa_lookup_sids_all(cli, tmp_ctx, 
-                                                   &lsa_policy,
-                                                   num_nocache, 
-                                                   sid_mem_nocache, 
-                                                   &domains_nocache, 
-                                                   &names_nocache, 
-                                                   &name_types_nocache);
+               status = rpccli_lsa_lookup_sids(cli, tmp_ctx, 
+                                               &lsa_policy,
+                                               num_nocache, 
+                                               sid_mem_nocache, 
+                                               &domains_nocache, 
+                                               &names_nocache, 
+                                               &name_types_nocache);
 
                if (NT_STATUS_IS_OK(status) ||
                    NT_STATUS_EQUAL(status, STATUS_SOME_UNMAPPED))