Author: jra
Date: 2006-09-15 14:18:52 +0000 (Fri, 15 Sep 2006)
New Revision: 18552

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=18552

Log:
Ensure the sitename matches before we SAF store a DC in ADS mode.
Jeremy.

Modified:
   branches/SAMBA_3_0/source/libads/ldap.c
   branches/SAMBA_3_0/source/nsswitch/winbindd_cm.c


Changeset:
Modified: branches/SAMBA_3_0/source/libads/ldap.c
===================================================================
--- branches/SAMBA_3_0/source/libads/ldap.c     2006-09-15 14:05:28 UTC (rev 
18551)
+++ branches/SAMBA_3_0/source/libads/ldap.c     2006-09-15 14:18:52 UTC (rev 
18552)
@@ -115,7 +115,6 @@
        return result;
 }
 
-#ifdef HAVE_KRB5
 /**********************************************
  Do client and server sitename match ?
 **********************************************/
@@ -139,7 +138,6 @@
                ads->config.client_site_name ? ads->config.client_site_name : 
"NULL"));
        return False;
 }
-#endif
 
 /*
   try a connection to a given ldap server, returning True and setting the 
servers IP
@@ -394,8 +392,10 @@
        }
 
        /* cache the successful connection for workgroup and realm */
-       saf_store( ads->server.workgroup, inet_ntoa(ads->ldap_ip));
-       saf_store( ads->server.realm, inet_ntoa(ads->ldap_ip));
+       if (ads_sitename_match(ads)) {
+               saf_store( ads->server.workgroup, inet_ntoa(ads->ldap_ip));
+               saf_store( ads->server.realm, inet_ntoa(ads->ldap_ip));
+       }
 
        ldap_set_option(ads->ld, LDAP_OPT_PROTOCOL_VERSION, &version);
 

Modified: branches/SAMBA_3_0/source/nsswitch/winbindd_cm.c
===================================================================
--- branches/SAMBA_3_0/source/nsswitch/winbindd_cm.c    2006-09-15 14:05:28 UTC 
(rev 18551)
+++ branches/SAMBA_3_0/source/nsswitch/winbindd_cm.c    2006-09-15 14:18:52 UTC 
(rev 18552)
@@ -754,7 +754,6 @@
                ads->auth.flags |= ADS_AUTH_NO_BIND;
 
                if (ads_try_connect( ads, inet_ntoa(ip) ) )  {
-                       char *sitename = sitename_fetch();
                        /* We got a cldap packet. */
                        fstrcpy(name, ads->config.ldap_server_name);
                        namecache_store(name, 0x20, 1, &ip_list);
@@ -769,9 +768,12 @@
                                create_local_private_krb5_conf_for_domain(realm,
                                                                domainname,
                                                                ip);
+
+                               /* Ensure we contact this DC also. */
+                               saf_store( domainname, name);
+                               saf_store( realm, name);
                        }
 #endif
-                       SAFE_FREE(sitename);
                        ads_destroy( &ads );
                        return True;
                }

Reply via email to