From: Günther Deschner Date: Thu, 17 Sep 2009 06:06:34 +0000 (+0200) Subject: s3-winbindd: add and use winbindd_lookup_names(). X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=afbe7c3605edcb8f7dfc64399681f23fa947fe57;p=thirdparty%2Fsamba.git s3-winbindd: add and use winbindd_lookup_names(). Guenther (cherry picked from commit 99c3fc19587431efda1ae6161453d84673b32071) --- diff --git a/source/winbindd/winbindd_proto.h b/source/winbindd/winbindd_proto.h index 84091c49795..9203c5a9743 100644 --- a/source/winbindd/winbindd_proto.h +++ b/source/winbindd/winbindd_proto.h @@ -82,6 +82,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 */ diff --git a/source/winbindd/winbindd_rpc.c b/source/winbindd/winbindd_rpc.c index f1dd52947ab..c1f1a6468df 100644 --- a/source/winbindd/winbindd_rpc.c +++ b/source/winbindd/winbindd_rpc.c @@ -277,11 +277,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; - POLICY_HND 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); @@ -311,23 +308,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; @@ -1229,6 +1212,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 = {