From 99c3fc19587431efda1ae6161453d84673b32071 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Thu, 17 Sep 2009 08:06:34 +0200 Subject: s3-winbindd: add and use winbindd_lookup_names(). Guenther --- source3/winbindd/winbindd_proto.h | 7 +++++ source3/winbindd/winbindd_rpc.c | 60 ++++++++++++++++++++++++++------------- 2 files changed, 47 insertions(+), 20 deletions(-) (limited to 'source3/winbindd') diff --git a/source3/winbindd/winbindd_proto.h b/source3/winbindd/winbindd_proto.h index 19224255e9..427579faf1 100644 --- a/source3/winbindd/winbindd_proto.h +++ b/source3/winbindd/winbindd_proto.h @@ -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 */ diff --git a/source3/winbindd/winbindd_rpc.c b/source3/winbindd/winbindd_rpc.c index 259ebc77c0..70eeae6408 100644 --- a/source3/winbindd/winbindd_rpc.c +++ b/source3/winbindd/winbindd_rpc.c @@ -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 = { -- cgit