summaryrefslogtreecommitdiff
path: root/source3/libsmb
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2006-08-30 05:52:31 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:38:59 -0500
commit7b7ce43b40888af7d2663e77d8a9e83c383c6b2d (patch)
treeb5db98353273e799a1f09490b374da4e8fc6b46b /source3/libsmb
parent2abab7ee6d04a62017d99578c274244a1cdd27b2 (diff)
downloadsamba-7b7ce43b40888af7d2663e77d8a9e83c383c6b2d.tar.gz
samba-7b7ce43b40888af7d2663e77d8a9e83c383c6b2d.tar.bz2
samba-7b7ce43b40888af7d2663e77d8a9e83c383c6b2d.zip
r17929: Ok, I think I finally figured out where to put
the code to redo the CLDAP query to restrict DC DNS lookups to the sitename. Jerry, please check to stop me going insane :-). Jeremy. (This used to be commit 8d22cc111579c57aec65be8884b41564b79b133a)
Diffstat (limited to 'source3/libsmb')
-rw-r--r--source3/libsmb/namequery_dc.c54
1 files changed, 42 insertions, 12 deletions
diff --git a/source3/libsmb/namequery_dc.c b/source3/libsmb/namequery_dc.c
index 4afd04a98f..b4ea90fde0 100644
--- a/source3/libsmb/namequery_dc.c
+++ b/source3/libsmb/namequery_dc.c
@@ -26,34 +26,65 @@
#include "includes.h"
/**************************************************************************
- Find the name and IP address for a server in he realm/domain
+ Find the name and IP address for a server in the realm/domain
*************************************************************************/
-static BOOL ads_dc_name(const char *domain, const char *realm, struct in_addr *dc_ip, fstring srv_name)
+static BOOL ads_dc_name(const char *domain,
+ const char *realm,
+ struct in_addr *dc_ip,
+ fstring srv_name)
{
ADS_STRUCT *ads;
+ char *sitename = sitename_fetch();
+ int i;
if (!realm && strequal(domain, lp_workgroup()))
realm = lp_realm();
- ads = ads_init(realm, domain, NULL);
- if (!ads)
- return False;
+ /* Try this 3 times then give up. */
+ for( i =0 ; i < 3; i++) {
+ ads = ads_init(realm, domain, NULL);
+ if (!ads) {
+ SAFE_FREE(sitename);
+ return False;
+ }
- DEBUG(4,("ads_dc_name: domain=%s\n", domain));
+ DEBUG(4,("ads_dc_name: domain=%s\n", domain));
#ifdef HAVE_ADS
- /* we don't need to bind, just connect */
- ads->auth.flags |= ADS_AUTH_NO_BIND;
-
- ads_connect(ads);
+ /* we don't need to bind, just connect */
+ ads->auth.flags |= ADS_AUTH_NO_BIND;
+ ads_connect(ads);
#endif
- if (!ads->config.realm) {
+ if (!ads->config.realm) {
+ SAFE_FREE(sitename);
+ ads_destroy(&ads);
+ return False;
+ }
+
+ /* Now we've found a server, see if our sitename
+ has changed. If so, we need to re-do the query
+ to ensure we only find servers in our site. */
+
+ if (!sitename_changed(sitename)) {
+ break;
+ }
+
+ ads_destroy(&ads);
+ }
+
+
+ if (i == 3) {
+ DEBUG(1,("ads_dc_name: sitename (now %s) keeps changing ???\n",
+ sitename));
+ SAFE_FREE(sitename);
ads_destroy(&ads);
return False;
}
+ SAFE_FREE(sitename);
+
fstrcpy(srv_name, ads->config.ldap_server_name);
strupper_m(srv_name);
*dc_ip = ads->ldap_ip;
@@ -157,4 +188,3 @@ BOOL get_dc_name(const char *domain, const char *realm, fstring srv_name, struct
return ret;
}
-