s3:libads/ldap.c: store the dc name in the saf cache as in all other places
[kai/samba.git] / source3 / libads / ldap.c
index 61e04d1e7c42acd618f393c4cbbb8021ddb72cac..cf8a7ebb1b3750f844df59faa6294d7c2ed38a47 100644 (file)
@@ -162,6 +162,11 @@ bool ads_closest_dc(ADS_STRUCT *ads)
                return True;
        }
 
+       if (ads->config.client_site_name == NULL) {
+               DEBUG(10,("ads_closest_dc: client belongs to no site\n"));
+               return True;
+       }
+
        DEBUG(10,("ads_closest_dc: %s is not the closest DC\n", 
                ads->config.ldap_server_name));
 
@@ -646,9 +651,8 @@ got_connection:
 
        /* cache the successful connection for workgroup and realm */
        if (ads_closest_dc(ads)) {
-               print_sockaddr(addr, sizeof(addr), &ads->ldap.ss);
-               saf_store( ads->server.workgroup, addr);
-               saf_store( ads->server.realm, addr);
+               saf_store( ads->server.workgroup, ads->config.ldap_server_name);
+               saf_store( ads->server.realm, ads->config.ldap_server_name);
        }
 
        ldap_set_option(ads->ldap.ld, LDAP_OPT_PROTOCOL_VERSION, &version);