r20860: Adding some small tweaks. When we have no sitename, there is no need to
authorGünther Deschner <gd@samba.org>
Wed, 17 Jan 2007 19:11:45 +0000 (19:11 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:17:14 +0000 (12:17 -0500)
ask for the list of DCs twice.

Guenther
(This used to be commit a9baf27e1348dd6dadd7a2fafdf9c269087b80ac)

source3/libads/kerberos.c
source3/nsswitch/winbindd_cm.c

index 95eed6fe27f3a8ce216551ce776f921c5d03230c..d35b59f4cdbfb30d1f154ec30f13d63ffc6bb86e 100644 (file)
@@ -484,18 +484,21 @@ static char *get_kdc_ip_string(char *mem_ctx, const char *realm, const char *sit
 
        /* Get the KDC's only in this site. */
 
-       get_kdc_list(realm, sitename, &ip_srv_site, &count_site);
+       if (sitename) {
 
-       for (i = 0; i < count_site; i++) {
-               if (ip_equal(ip_srv_site[i].ip, primary_ip)) {
-                       continue;
-               }
-               /* Append to the string - inefficient but not done often. */
-               kdc_str = talloc_asprintf(mem_ctx, "%s\tkdc = %s\n",
-                       kdc_str, inet_ntoa(ip_srv_site[i].ip));
-               if (!kdc_str) {
-                       SAFE_FREE(ip_srv_site);
-                       return NULL;
+               get_kdc_list(realm, sitename, &ip_srv_site, &count_site);
+
+               for (i = 0; i < count_site; i++) {
+                       if (ip_equal(ip_srv_site[i].ip, primary_ip)) {
+                               continue;
+                       }
+                       /* Append to the string - inefficient but not done often. */
+                       kdc_str = talloc_asprintf(mem_ctx, "%s\tkdc = %s\n",
+                               kdc_str, inet_ntoa(ip_srv_site[i].ip));
+                       if (!kdc_str) {
+                               SAFE_FREE(ip_srv_site);
+                               return NULL;
+                       }
                }
        }
 
index 70ab9b0582503bb5e4543aac0ae1da64369fb6bb..c854efd9b2533a41018e3b93d1bcf77208bf433f 100644 (file)
@@ -1121,18 +1121,20 @@ static BOOL get_dcs(TALLOC_CTX *mem_ctx, const struct winbindd_domain *domain,
                get_dc_name(domain->name, lp_realm(), dcname, &ip);
 
                sitename = sitename_fetch();
+               if (sitename) {
 
-               /* Do the site-specific AD dns lookup first. */
-               get_sorted_dc_list(domain->alt_name, sitename, &ip_list, &iplist_size, True);
+                       /* Do the site-specific AD dns lookup first. */
+                       get_sorted_dc_list(domain->alt_name, sitename, &ip_list, &iplist_size, True);
 
-               for ( i=0; i<iplist_size; i++ ) {
-                       add_one_dc_unique(mem_ctx, domain->name, inet_ntoa(ip_list[i].ip),
-                                               ip_list[i].ip, dcs, num_dcs);
-               }
+                       for ( i=0; i<iplist_size; i++ ) {
+                               add_one_dc_unique(mem_ctx, domain->name, inet_ntoa(ip_list[i].ip),
+                                                       ip_list[i].ip, dcs, num_dcs);
+                       }
 
-               SAFE_FREE(ip_list);
-               SAFE_FREE(sitename);
-               iplist_size = 0;
+                       SAFE_FREE(ip_list);
+                       SAFE_FREE(sitename);
+                       iplist_size = 0;
+               }
 
                /* Now we add DCs from the main AD dns lookup. */
                get_sorted_dc_list(domain->alt_name, NULL, &ip_list, &iplist_size, True);