From ff3ce9016a43906df55a0922f0697c91d255de88 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 2 Aug 2009 16:52:19 +0200 Subject: s3:winbind: Make wcache_lookup_useraliases available publically --- source3/winbindd/winbindd_cache.c | 107 ++++++++++++++++++++++++++------------ 1 file changed, 74 insertions(+), 33 deletions(-) (limited to 'source3/winbindd/winbindd_cache.c') diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c index 270b9f310d..ea3f00e6d8 100644 --- a/source3/winbindd/winbindd_cache.c +++ b/source3/winbindd/winbindd_cache.c @@ -2122,58 +2122,74 @@ skip_save: return status; } -static NTSTATUS lookup_useraliases(struct winbindd_domain *domain, - TALLOC_CTX *mem_ctx, - uint32 num_sids, const DOM_SID *sids, - uint32 *num_aliases, uint32 **alias_rids) +static char *wcache_make_sidlist(TALLOC_CTX *mem_ctx, uint32_t num_sids, + const struct dom_sid *sids) +{ + uint32_t i; + char *sidlist; + + sidlist = talloc_strdup(mem_ctx, ""); + if (sidlist == NULL) { + return NULL; + } + for (i=0; itdb) - goto do_query; + if (cache->tdb == NULL) { + return NT_STATUS_NOT_FOUND; + } if (num_sids == 0) { - *num_aliases = 0; - *alias_rids = NULL; + *pnum_aliases = 0; + *paliases = NULL; return NT_STATUS_OK; } /* We need to cache indexed by the whole list of SIDs, the aliases * resulting might come from any of the SIDs. */ - for (i=0; istatus; @@ -2181,9 +2197,29 @@ static NTSTATUS lookup_useraliases(struct winbindd_domain *domain, "status %s\n", domain->name, nt_errstr(status))); centry_free(centry); + + *pnum_aliases = num_aliases; + *paliases = aliases; + return status; +} + +static NTSTATUS lookup_useraliases(struct winbindd_domain *domain, + TALLOC_CTX *mem_ctx, + uint32 num_sids, const DOM_SID *sids, + uint32 *num_aliases, uint32 **alias_rids) +{ + struct cache_entry *centry = NULL; + NTSTATUS status; + char *sidlist; + int i; + + status = wcache_lookup_useraliases(domain, mem_ctx, num_sids, sids, + num_aliases, alias_rids); + if (!NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) { + return status; + } - do_query: (*num_aliases) = 0; (*alias_rids) = NULL; @@ -2193,6 +2229,11 @@ static NTSTATUS lookup_useraliases(struct winbindd_domain *domain, DEBUG(10,("lookup_usergroups: [Cached] - doing backend query for info " "for domain %s\n", domain->name )); + sidlist = wcache_make_sidlist(talloc_tos(), num_sids, sids); + if (sidlist == NULL) { + return NT_STATUS_NO_MEMORY; + } + status = domain->backend->lookup_useraliases(domain, mem_ctx, num_sids, sids, num_aliases, alias_rids); -- cgit