s3-winbindd: add and use winbindd_lookup_names().
authorGünther Deschner <gd@samba.org>
Thu, 17 Sep 2009 06:06:34 +0000 (08:06 +0200)
committerGünther Deschner <gd@samba.org>
Thu, 17 Sep 2009 06:54:31 +0000 (08:54 +0200)
Guenther

source3/winbindd/winbindd_proto.h
source3/winbindd/winbindd_rpc.c

index 19224255e9db6674efd6ce08dea8cd9d31ef2598..427579faf15cba162c753e0dfa972cc9b30dd6d0 100644 (file)
@@ -72,6 +72,13 @@ NTSTATUS winbindd_lookup_sids(TALLOC_CTX *mem_ctx,
                              char ***domains,
                              char ***names,
                              enum lsa_SidType **types);
+NTSTATUS winbindd_lookup_names(TALLOC_CTX *mem_ctx,
+                              struct winbindd_domain *domain,
+                              uint32_t num_names,
+                              const char **names,
+                              const char ***domains,
+                              struct dom_sid **sids,
+                              enum lsa_SidType **types);
 
 /* The following definitions come from winbindd/winbindd_async.c  */
 
index 259ebc77c07542625b6f8620335ae533a3913257..70eeae6408b6f1a9f07f23f228d404194340ece5 100644 (file)
@@ -278,11 +278,8 @@ static NTSTATUS msrpc_name_to_sid(struct winbindd_domain *domain,
        DOM_SID *sids = NULL;
        enum lsa_SidType *types = NULL;
        char *full_name = NULL;
-       struct rpc_pipe_client *cli;
-       struct policy_handle lsa_policy;
        NTSTATUS name_map_status = NT_STATUS_UNSUCCESSFUL;
        char *mapped_name = NULL;
-       unsigned int orig_timeout;
 
        if (name == NULL || *name=='\0') {
                full_name = talloc_asprintf(mem_ctx, "%s", domain_name);
@@ -312,23 +309,9 @@ static NTSTATUS msrpc_name_to_sid(struct winbindd_domain *domain,
        DEBUG(3,("name_to_sid [rpc] %s for domain %s\n",
                 full_name?full_name:"", domain_name ));
 
-       result = cm_connect_lsa(domain, mem_ctx, &cli, &lsa_policy);
-       if (!NT_STATUS_IS_OK(result))
-               return result;
-
-       /*
-        * This call can take a long time
-        * allow the server to time out.
-        * 35 seconds should do it.
-        */
-       orig_timeout = rpccli_set_timeout(cli, 35000);
-
-       result = rpccli_lsa_lookup_names(cli, mem_ctx, &lsa_policy, 1, 
-                                        (const char**) &full_name, NULL, 1, &sids, &types);
-
-       /* And restore our original timeout. */
-       rpccli_set_timeout(cli, orig_timeout);
-
+       result = winbindd_lookup_names(mem_ctx, domain, 1,
+                                      (const char **)&full_name, NULL,
+                                      &sids, &types);
        if (!NT_STATUS_IS_OK(result))
                return result;
 
@@ -1234,6 +1217,43 @@ NTSTATUS winbindd_lookup_sids(TALLOC_CTX *mem_ctx,
        return status;
 }
 
+NTSTATUS winbindd_lookup_names(TALLOC_CTX *mem_ctx,
+                              struct winbindd_domain *domain,
+                              uint32_t num_names,
+                              const char **names,
+                              const char ***domains,
+                              struct dom_sid **sids,
+                              enum lsa_SidType **types)
+{
+       NTSTATUS status;
+       struct rpc_pipe_client *cli = NULL;
+       struct policy_handle lsa_policy;
+       unsigned int orig_timeout;
+
+       status = cm_connect_lsa(domain, mem_ctx, &cli, &lsa_policy);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
+
+       /*
+        * This call can take a long time
+        * allow the server to time out.
+        * 35 seconds should do it.
+        */
+       orig_timeout = rpccli_set_timeout(cli, 35000);
+
+       status = rpccli_lsa_lookup_names(cli, mem_ctx, &lsa_policy, num_names,
+                                        names, domains, 1, sids, types);
+
+       /* And restore our original timeout. */
+       rpccli_set_timeout(cli, orig_timeout);
+
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
+
+       return status;
+}
 
 /* the rpc backend methods are exposed via this structure */
 struct winbindd_methods msrpc_methods = {