From ad1fbe29fbeea48381c7bedd78f7a45d07ad14d5 Mon Sep 17 00:00:00 2001 From: Christof Schmitt Date: Thu, 21 Feb 2013 12:31:41 -0700 Subject: s3-winbindd: Move connection to AD server from idmap_ad Having this in a common place allows reuse by other idmap modules. Reviewed-by: Andrew Bartlett --- source3/winbindd/idmap_ad.c | 49 ++++----------------------------------------- 1 file changed, 4 insertions(+), 45 deletions(-) (limited to 'source3/winbindd/idmap_ad.c') diff --git a/source3/winbindd/idmap_ad.c b/source3/winbindd/idmap_ad.c index 5b9c3774f6..5bafa90299 100644 --- a/source3/winbindd/idmap_ad.c +++ b/source3/winbindd/idmap_ad.c @@ -56,58 +56,17 @@ struct idmap_ad_context { /************************************************************************ ***********************************************************************/ -static ADS_STATUS ad_idmap_cached_connection_internal(struct idmap_domain *dom) +static ADS_STATUS ad_idmap_cached_connection(struct idmap_domain *dom) { - struct idmap_ad_context *ctx; - char *ldap_server, *realm, *password; - struct winbindd_domain *wb_dom; + ADS_STATUS status; + struct idmap_ad_context * ctx; DEBUG(10, ("ad_idmap_cached_connection: called for domain '%s'\n", dom->name)); ctx = talloc_get_type(dom->private_data, struct idmap_ad_context); - ads_cached_connection_reuse(&ctx->ads); - if (ctx->ads != NULL) { - return ADS_SUCCESS; - } - - /* - * At this point we only have the NetBIOS domain name. - * Check if we can get server nam and realm from SAF cache - * and the domain list. - */ - ldap_server = saf_fetch(dom->name); - DEBUG(10, ("ldap_server from saf cache: '%s'\n", ldap_server?ldap_server:"")); - - wb_dom = find_domain_from_name_noinit(dom->name); - if (wb_dom == NULL) { - DEBUG(10, ("find_domain_from_name_noinit did not find domain '%s'\n", - dom->name)); - realm = NULL; - } else { - DEBUG(10, ("find_domain_from_name_noinit found realm '%s' for " - " domain '%s'\n", wb_dom->alt_name, dom->name)); - realm = wb_dom->alt_name; - } - - /* the machine acct password might have change - fetch it every time */ - password = secrets_fetch_machine_password(lp_workgroup(), NULL, NULL); - realm = SMB_STRDUP(lp_realm()); - - return ads_cached_connection_connect(&ctx->ads, realm, dom->name, - ldap_server, password, realm, 0); -} - -/************************************************************************ - ***********************************************************************/ - -static ADS_STATUS ad_idmap_cached_connection(struct idmap_domain *dom) -{ - ADS_STATUS status; - struct idmap_ad_context * ctx; - - status = ad_idmap_cached_connection_internal(dom); + status = ads_idmap_cached_connection(&ctx->ads, dom->name); if (!ADS_ERR_OK(status)) { return status; } -- cgit