diff options
Diffstat (limited to 'source3/utils')
-rw-r--r-- | source3/utils/net_ads.c | 12 | ||||
-rw-r--r-- | source3/utils/net_lookup.c | 21 |
2 files changed, 17 insertions, 16 deletions
diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index 8c35f201ad..bd67983954 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -218,8 +218,6 @@ static ADS_STATUS ads_startup_int(BOOL only_own_domain, uint32 auth_flags, ADS_S char *cp; const char *realm = NULL; BOOL tried_closest_dc = False; - BOOL closest_dc = False; - BOOL site_matches = False; /* lp_realm() should be handled by a command line param, However, the join requires that realm be set in smb.conf @@ -290,7 +288,7 @@ retry: return status; } - if (!need_password && !second_time) { + if (!need_password && !second_time && !(auth_flags & ADS_AUTH_NO_BIND)) { need_password = True; second_time = True; goto retry; @@ -304,17 +302,11 @@ retry: * This is done by reconnecting to ADS because only the first call to * ads_connect will give us our own sitename */ - closest_dc = (ads->config.flags & ADS_CLOSEST); - site_matches = ads_sitename_match(ads); - - DEBUG(10,("ads_startup_int: DC %s closest DC\n", closest_dc ? "is":"is *NOT*")); - DEBUG(10,("ads_startup_int: sitenames %s match\n", site_matches ? "do":"do *NOT*")); - if ((only_own_domain || !opt_host) && !tried_closest_dc) { tried_closest_dc = True; /* avoid loop */ - if (!ads_closest_dc(ads)) { + if (!ads->config.tried_closest_dc) { namecache_delete(ads->server.realm, 0x1C); namecache_delete(ads->server.workgroup, 0x1C); diff --git a/source3/utils/net_lookup.c b/source3/utils/net_lookup.c index b768089fff..8e223e67f3 100644 --- a/source3/utils/net_lookup.c +++ b/source3/utils/net_lookup.c @@ -84,6 +84,7 @@ static int net_lookup_ldap(int argc, const char **argv) struct hostent *hostent; struct dns_rr_srv *dcs = NULL; int numdcs = 0; + char *sitename = sitename_fetch(); TALLOC_CTX *ctx; NTSTATUS status; @@ -94,22 +95,24 @@ static int net_lookup_ldap(int argc, const char **argv) if ( (ctx = talloc_init("net_lookup_ldap")) == NULL ) { d_fprintf(stderr, "net_lookup_ldap: talloc_inti() failed!\n"); + SAFE_FREE(sitename); return -1; } DEBUG(9, ("Lookup up ldap for domain %s\n", domain)); - status = ads_dns_query_dcs( ctx, domain, &dcs, &numdcs ); + status = ads_dns_query_dcs( ctx, domain, sitename, &dcs, &numdcs ); if ( NT_STATUS_IS_OK(status) && numdcs ) { print_ldap_srvlist(dcs, numdcs); TALLOC_FREE( ctx ); - + SAFE_FREE(sitename); return 0; } DEBUG(9, ("Looking up DC for domain %s\n", domain)); if (!get_pdc_ip(domain, &addr)) { TALLOC_FREE( ctx ); + SAFE_FREE(sitename); return -1; } @@ -117,6 +120,7 @@ static int net_lookup_ldap(int argc, const char **argv) AF_INET); if (!hostent) { TALLOC_FREE( ctx ); + SAFE_FREE(sitename); return -1; } @@ -124,22 +128,23 @@ static int net_lookup_ldap(int argc, const char **argv) domain = strchr(hostent->h_name, '.'); if (!domain) { TALLOC_FREE( ctx ); + SAFE_FREE(sitename); return -1; } domain++; DEBUG(9, ("Looking up ldap for domain %s\n", domain)); - status = ads_dns_query_dcs( ctx, domain, &dcs, &numdcs ); + status = ads_dns_query_dcs( ctx, domain, sitename, &dcs, &numdcs ); if ( NT_STATUS_IS_OK(status) && numdcs ) { print_ldap_srvlist(dcs, numdcs); TALLOC_FREE( ctx ); - + SAFE_FREE(sitename); return 0; } TALLOC_FREE( ctx ); - + SAFE_FREE(sitename); return -1; #endif @@ -153,6 +158,7 @@ static int net_lookup_dc(int argc, const char **argv) struct in_addr addr; char *pdc_str = NULL; const char *domain=opt_target_workgroup; + char *sitename = NULL; int count, i; if (argc > 0) @@ -165,10 +171,13 @@ static int net_lookup_dc(int argc, const char **argv) asprintf(&pdc_str, "%s", inet_ntoa(addr)); d_printf("%s\n", pdc_str); - if (!NT_STATUS_IS_OK(get_sorted_dc_list(domain, &ip_list, &count, False))) { + sitename = sitename_fetch(); + if (!NT_STATUS_IS_OK(get_sorted_dc_list(domain, sitename, &ip_list, &count, False))) { SAFE_FREE(pdc_str); + SAFE_FREE(sitename); return 0; } + SAFE_FREE(sitename); for (i=0;i<count;i++) { char *dc_str = inet_ntoa(ip_list[i].ip); if (!strequal(pdc_str, dc_str)) |