summaryrefslogtreecommitdiffstats
path: root/source3/utils/net_lookup.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-01-17 18:25:35 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:17:14 -0500
commitbfd099e148ed97394bc858e746a1a998a71ac43c (patch)
treee93e1c1227f117c5c532605bec396b543844b103 /source3/utils/net_lookup.c
parent90f59d441223ba9b32b0d788901c9de5cf4b3bc7 (diff)
downloadsamba-bfd099e148ed97394bc858e746a1a998a71ac43c.tar.gz
samba-bfd099e148ed97394bc858e746a1a998a71ac43c.tar.xz
samba-bfd099e148ed97394bc858e746a1a998a71ac43c.zip
r20857: Silence gives assent :-). Checking in the fix for
site support in a network where many DC's are down. I heard via Volker there is still a bug w.r.t the wrong site being chosen with trusted domains but we'll have to layer that fix on top of this. Gd - complain if this doesn't work for you. Jeremy. (This used to be commit 97e248f89ac6548274f03f2ae7583a255da5ddb3)
Diffstat (limited to 'source3/utils/net_lookup.c')
-rw-r--r--source3/utils/net_lookup.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/source3/utils/net_lookup.c b/source3/utils/net_lookup.c
index b768089fff5..8e223e67f3b 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))