summaryrefslogtreecommitdiff
path: root/source3/winbindd/winbindd_cache.c
diff options
context:
space:
mode:
authorChristian Ambach <christian.ambach@de.ibm.com>2010-10-29 15:53:20 +0200
committerVolker Lendecke <vl@samba.org>2010-11-08 13:39:51 +0100
commit51ddddfa9f832d1a9aa207c7a13393e3c11b5dc3 (patch)
tree2cb73c5635738544a45f82dfb93d666a336f3748 /source3/winbindd/winbindd_cache.c
parent69155e41037d42ca58efa7ef749cb05654ac27e2 (diff)
downloadsamba-51ddddfa9f832d1a9aa207c7a13393e3c11b5dc3.tar.gz
samba-51ddddfa9f832d1a9aa207c7a13393e3c11b5dc3.tar.bz2
samba-51ddddfa9f832d1a9aa207c7a13393e3c11b5dc3.zip
s3:winbind add wcache_tdc_fetch_domainbysid
add a function to lookup a domain in the winbind cache by domain SID
Diffstat (limited to 'source3/winbindd/winbindd_cache.c')
-rw-r--r--source3/winbindd/winbindd_cache.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c
index c6ef293134..9363a70a21 100644
--- a/source3/winbindd/winbindd_cache.c
+++ b/source3/winbindd/winbindd_cache.c
@@ -4542,6 +4542,58 @@ struct winbindd_tdc_domain * wcache_tdc_fetch_domain( TALLOC_CTX *ctx, const cha
return d;
}
+/*********************************************************************
+ ********************************************************************/
+
+struct winbindd_tdc_domain*
+ wcache_tdc_fetch_domainbysid(TALLOC_CTX *ctx,
+ const struct dom_sid *sid)
+{
+ struct winbindd_tdc_domain *dom_list = NULL;
+ size_t num_domains = 0;
+ int i;
+ struct winbindd_tdc_domain *d = NULL;
+
+ DEBUG(10,("wcache_tdc_fetch_domainbysid: Searching for domain %s\n",
+ sid_string_dbg(sid)));
+
+ if (!init_wcache()) {
+ return false;
+ }
+
+ /* fetch the list */
+
+ wcache_tdc_fetch_list(&dom_list, &num_domains);
+
+ for (i = 0; i<num_domains; i++) {
+ if (sid_equal(sid, &(dom_list[i].sid))) {
+ DEBUG(10, ("wcache_tdc_fetch_domainbysid: "
+ "Found domain %s for SID %s\n",
+ dom_list[i].domain_name,
+ sid_string_dbg(sid)));
+
+ d = TALLOC_P(ctx, struct winbindd_tdc_domain);
+ if (!d)
+ break;
+
+ d->domain_name = talloc_strdup(d,
+ dom_list[i].domain_name);
+
+ d->dns_name = talloc_strdup(d, dom_list[i].dns_name);
+ sid_copy(&d->sid, &dom_list[i].sid);
+ d->trust_flags = dom_list[i].trust_flags;
+ d->trust_type = dom_list[i].trust_type;
+ d->trust_attribs = dom_list[i].trust_attribs;
+
+ break;
+ }
+ }
+
+ TALLOC_FREE(dom_list);
+
+ return d;
+}
+
/*********************************************************************
********************************************************************/