summaryrefslogtreecommitdiff
path: root/source3/winbindd/idmap_ad.c
diff options
context:
space:
mode:
authorChristof Schmitt <christof.schmitt@us.ibm.com>2013-02-21 12:31:37 -0700
committerAndrew Bartlett <abartlet@samba.org>2013-03-09 06:30:22 +0100
commitbaf9b78d47079b81cf33682ee481cf6e30ed89e9 (patch)
treec536ff29100805495b2bab6e8c9a3911a03a617e /source3/winbindd/idmap_ad.c
parent0c4e467c1cc661552bfd6745825e2106ec8279d7 (diff)
downloadsamba-baf9b78d47079b81cf33682ee481cf6e30ed89e9.tar.gz
samba-baf9b78d47079b81cf33682ee481cf6e30ed89e9.tar.bz2
samba-baf9b78d47079b81cf33682ee481cf6e30ed89e9.zip
s3-winbindd: Use common helper function for connecting to ADS
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source3/winbindd/idmap_ad.c')
-rw-r--r--source3/winbindd/idmap_ad.c41
1 files changed, 5 insertions, 36 deletions
diff --git a/source3/winbindd/idmap_ad.c b/source3/winbindd/idmap_ad.c
index 0e00a340bf..5b9c3774f6 100644
--- a/source3/winbindd/idmap_ad.c
+++ b/source3/winbindd/idmap_ad.c
@@ -58,13 +58,8 @@ struct idmap_ad_context {
static ADS_STATUS ad_idmap_cached_connection_internal(struct idmap_domain *dom)
{
- ADS_STRUCT *ads;
- ADS_STATUS status;
- fstring dc_name;
- struct sockaddr_storage dc_ip;
struct idmap_ad_context *ctx;
- char *ldap_server = NULL;
- char *realm = NULL;
+ char *ldap_server, *realm, *password;
struct winbindd_domain *wb_dom;
DEBUG(10, ("ad_idmap_cached_connection: called for domain '%s'\n",
@@ -77,9 +72,6 @@ static ADS_STATUS ad_idmap_cached_connection_internal(struct idmap_domain *dom)
return ADS_SUCCESS;
}
- /* we don't want this to affect the users ccache */
- setenv("KRB5CCNAME", WINBIND_CCACHE_NAME, 1);
-
/*
* At this point we only have the NetBIOS domain name.
* Check if we can get server nam and realm from SAF cache
@@ -99,35 +91,12 @@ static ADS_STATUS ad_idmap_cached_connection_internal(struct idmap_domain *dom)
realm = wb_dom->alt_name;
}
- if ( (ads = ads_init(realm, dom->name, ldap_server)) == NULL ) {
- DEBUG(1,("ads_init failed\n"));
- return ADS_ERROR_NT(NT_STATUS_NO_MEMORY);
- }
-
/* the machine acct password might have change - fetch it every time */
- SAFE_FREE(ads->auth.password);
- ads->auth.password = secrets_fetch_machine_password(lp_workgroup(), NULL, NULL);
-
- SAFE_FREE(ads->auth.realm);
- ads->auth.realm = SMB_STRDUP(lp_realm());
-
- /* setup server affinity */
-
- get_dc_name(dom->name, realm, dc_name, &dc_ip );
-
- status = ads_connect(ads);
- if (!ADS_ERR_OK(status)) {
- DEBUG(1, ("ad_idmap_cached_connection_internal: failed to "
- "connect to AD\n"));
- ads_destroy(&ads);
- return status;
- }
-
- ads->is_mine = False;
-
- ctx->ads = ads;
+ password = secrets_fetch_machine_password(lp_workgroup(), NULL, NULL);
+ realm = SMB_STRDUP(lp_realm());
- return ADS_SUCCESS;
+ return ads_cached_connection_connect(&ctx->ads, realm, dom->name,
+ ldap_server, password, realm, 0);
}
/************************************************************************