diff options
author | Andrew Tridgell <tridge@samba.org> | 2002-04-19 03:00:29 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2002-04-19 03:00:29 +0000 |
commit | fc78c773f8216df1bbaa88d9007cf3f5df386e3d (patch) | |
tree | 961fa8a62c1fb4a15bfa617aa0bd58f143c47d0f | |
parent | e762f93821a21f460fecf7452d2363574ab04dad (diff) | |
download | samba-fc78c773f8216df1bbaa88d9007cf3f5df386e3d.tar.gz samba-fc78c773f8216df1bbaa88d9007cf3f5df386e3d.tar.bz2 samba-fc78c773f8216df1bbaa88d9007cf3f5df386e3d.zip |
fixed trust relationships in ADS winbindd after breaking them with my BDC changes ...
(This used to be commit 8096032663690eafb6bb8b4f405d6231389d4f80)
-rw-r--r-- | source3/libads/ads_struct.c | 9 | ||||
-rw-r--r-- | source3/libads/ldap.c | 8 | ||||
-rw-r--r-- | source3/nsswitch/winbindd_ads.c | 2 |
3 files changed, 13 insertions, 6 deletions
diff --git a/source3/libads/ads_struct.c b/source3/libads/ads_struct.c index 816b616097..638dc0b22e 100644 --- a/source3/libads/ads_struct.c +++ b/source3/libads/ads_struct.c @@ -81,7 +81,8 @@ static char *find_ldap_server(ADS_STRUCT *ads) char *list = NULL; struct in_addr ip; - if (ads->realm && + if (ads->realm && + strcasecmp(ads->workgroup, lp_workgroup()) == 0 && ldap_domain2hostlist(ads->realm, &list) == LDAP_SUCCESS) { char *p; p = strchr(list, ':'); @@ -151,8 +152,10 @@ ADS_STRUCT *ads_init(const char *realm, ads->bind_path = ads_build_dn(ads->realm); } if (!ads->ldap_server) { - ads->ldap_server = strdup(lp_ads_server()); - if (!ads->ldap_server[0]) { + if (strcasecmp(ads->workgroup, lp_workgroup()) == 0) { + ads->ldap_server = strdup(lp_ads_server()); + } + if (!ads->ldap_server || !ads->ldap_server[0]) { ads->ldap_server = find_ldap_server(ads); } } diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c index 3b787c6a8f..543e53bcf8 100644 --- a/source3/libads/ldap.c +++ b/source3/libads/ldap.c @@ -45,7 +45,11 @@ ADS_STATUS ads_connect(ADS_STRUCT *ads) ads->last_attempt = time(NULL); - ads->ld = ldap_open(ads->ldap_server, ads->ldap_port); + ads->ld = NULL; + + if (ads->ldap_server) { + ads->ld = ldap_open(ads->ldap_server, ads->ldap_port); + } /* if that failed then try each of the BDC's in turn */ if (!ads->ld) { @@ -60,7 +64,7 @@ ADS_STATUS ads_connect(ADS_STRUCT *ads) if (ads->ld) break; } if (ads->ld) { - free(ads->ldap_server); + SAFE_FREE(ads->ldap_server); ads->ldap_server = strdup(inet_ntoa(ip_list[i])); } free(ip_list); diff --git a/source3/nsswitch/winbindd_ads.c b/source3/nsswitch/winbindd_ads.c index 6c00ddb95f..c16231b25d 100644 --- a/source3/nsswitch/winbindd_ads.c +++ b/source3/nsswitch/winbindd_ads.c @@ -58,7 +58,7 @@ ADS_STATUS ads_do_search_retry(ADS_STRUCT *ads, const char *bind_path, int scope if (*res) ads_msgfree(ads, *res); *res = NULL; - DEBUG(1,("Reopening ads connection to %s after error %s\n", + DEBUG(3,("Reopening ads connection to %s after error %s\n", ads->ldap_server, ads_errstr(status))); if (ads->ld) { ldap_unbind(ads->ld); |