diff options
author | Tim Potter <tpot@samba.org> | 2002-11-06 05:14:15 +0000 |
---|---|---|
committer | Tim Potter <tpot@samba.org> | 2002-11-06 05:14:15 +0000 |
commit | ab1cf8d1cf447e85063b43b65fa05c8b4bfde2a9 (patch) | |
tree | de41e9906d94ea9b2a1d2c12920d23b9640d3e83 /source3/nsswitch | |
parent | d21a06bbb44a0044657de38c1eb544be8c335918 (diff) | |
download | samba-ab1cf8d1cf447e85063b43b65fa05c8b4bfde2a9.tar.gz samba-ab1cf8d1cf447e85063b43b65fa05c8b4bfde2a9.tar.bz2 samba-ab1cf8d1cf447e85063b43b65fa05c8b4bfde2a9.zip |
Merge of get_dc_list() api change from HEAD.
(This used to be commit 6ba7847ce2756fde94e530fd0bf2a055f3e27373)
Diffstat (limited to 'source3/nsswitch')
-rw-r--r-- | source3/nsswitch/winbindd_cm.c | 71 |
1 files changed, 17 insertions, 54 deletions
diff --git a/source3/nsswitch/winbindd_cm.c b/source3/nsswitch/winbindd_cm.c index bbf5b90495..b4d5a664b2 100644 --- a/source3/nsswitch/winbindd_cm.c +++ b/source3/nsswitch/winbindd_cm.c @@ -140,70 +140,32 @@ static BOOL cm_ads_find_dc(const char *domain, struct in_addr *dc_ip, fstring sr */ static BOOL cm_rpc_find_dc(const char *domain, struct in_addr *dc_ip, fstring srv_name) { - struct in_addr *ip_list = NULL, exclude_ip; + struct in_addr *ip_list = NULL; int count, i; - zero_ip(&exclude_ip); - - /* Lookup domain controller name. Try the real PDC first to avoid - SAM sync delays */ - - if (get_dc_list(True, domain, &ip_list, &count)) { - if (name_status_find(domain, 0x1c, 0x20, ip_list[0], srv_name)) { - *dc_ip = ip_list[0]; - SAFE_FREE(ip_list); - return True; + if (!get_dc_list(domain, &ip_list, &count)) { + struct in_addr pdc_ip; + + if (!get_pdc_ip(domain, &pdc_ip)) { + DEBUG(3, ("Could not look up any DCs for domain %s\n", + domain)); + return False; } - /* Didn't get name, remember not to talk to this DC. */ - exclude_ip = ip_list[0]; - SAFE_FREE(ip_list); - } - if (!get_dc_list(False, domain, &ip_list, &count)) { - DEBUG(3, ("Could not look up dc's for domain %s\n", domain)); - return False; - } + ip_list = (struct in_addr *)malloc(sizeof(struct in_addr)); - /* Remove the entry we've already failed with (should be the PDC). */ - for (i = 0; i < count; i++) { - if (ip_equal( exclude_ip, ip_list[i])) - zero_ip(&ip_list[i]); - } - - /* Pick a nice close server */ - /* Look for DC on local net */ - for (i = 0; i < count; i++) { - if (is_zero_ip(ip_list[i])) - continue; + if (!ip_list) + return False; - if (!is_local_net(ip_list[i])) - continue; - - if (name_status_find(domain, 0x1c, 0x20, ip_list[i], srv_name)) { - *dc_ip = ip_list[i]; - SAFE_FREE(ip_list); - return True; - } - zero_ip(&ip_list[i]); + ip_list[0] = pdc_ip; + count = 1; } - /* - * Secondly try and contact a random PDC/BDC. - */ - - i = (sys_random() % count); - - if (!is_zero_ip(ip_list[i]) && - name_status_find(domain, 0x1c, 0x20, - ip_list[i], srv_name)) { - *dc_ip = ip_list[i]; - SAFE_FREE(ip_list); - return True; + /* Pick a nice close server */ + if (count > 1) { + qsort(ip_list, count, sizeof(struct in_addr), QSORT_CAST ip_compare); } - zero_ip(&ip_list[i]); /* Tried and failed. */ - /* Finally return first DC that we can contact using a node - status */ for (i = 0; i < count; i++) { if (is_zero_ip(ip_list[i])) continue; @@ -215,6 +177,7 @@ static BOOL cm_rpc_find_dc(const char *domain, struct in_addr *dc_ip, fstring sr } } + SAFE_FREE(ip_list); return False; |