summaryrefslogtreecommitdiff
path: root/source3/libsmb/namequery_dc.c
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2003-06-23 19:05:23 +0000
committerGerald Carter <jerry@samba.org>2003-06-23 19:05:23 +0000
commitf36c96d59c79a51610bb5a1fc42ac62bd8d08401 (patch)
tree69560bd452906389aab36ac7eb8109de7ff32ccc /source3/libsmb/namequery_dc.c
parentd21358308a2a2c86b4e9d23922c7c940b5d1b012 (diff)
downloadsamba-f36c96d59c79a51610bb5a1fc42ac62bd8d08401.tar.gz
samba-f36c96d59c79a51610bb5a1fc42ac62bd8d08401.tar.bz2
samba-f36c96d59c79a51610bb5a1fc42ac62bd8d08401.zip
* s/get_dc_name/rpc_dc_name/g (revert a previous change)
* move back to qsort() for sorting IP address in get_dc_list() * remove dc_name_cache in cm_get_dc_name() since it slowed things down more than it helped. I've made a note of where to add in the negative connection cache in the ads code. Will come back to that. * fix rpcclient to use PRINTER_ALL_ACCESS for set printer (instead of MAX_ALLOWED) * only enumerate domain local groups in our domain * simplify ldap search for seqnum in winbindd's rpc backend (This used to be commit f8cab8635b02b205b4031279cedd804c1fb22c5b)
Diffstat (limited to 'source3/libsmb/namequery_dc.c')
-rw-r--r--source3/libsmb/namequery_dc.c76
1 files changed, 9 insertions, 67 deletions
diff --git a/source3/libsmb/namequery_dc.c b/source3/libsmb/namequery_dc.c
index c162e34027..ac1f9a54de 100644
--- a/source3/libsmb/namequery_dc.c
+++ b/source3/libsmb/namequery_dc.c
@@ -160,7 +160,7 @@ void flush_negative_conn_cache( void )
valid since we have already done a name_status_find on it
***************************************************************************/
-BOOL get_dc_name(const char *domain, fstring srv_name, struct in_addr *ip_out)
+BOOL rpc_dc_name(const char *domain, fstring srv_name, struct in_addr *ip_out)
{
struct in_addr *ip_list = NULL, dc_ip, exclude_ip;
int count, i;
@@ -176,7 +176,7 @@ BOOL get_dc_name(const char *domain, fstring srv_name, struct in_addr *ip_out)
if ( use_pdc_only && get_pdc_ip(domain, &dc_ip) )
{
- DEBUG(10,("get_dc_name: Atempting to lookup PDC to avoid sam sync delays\n"));
+ DEBUG(10,("rpc_dc_name: Atempting to lookup PDC to avoid sam sync delays\n"));
/* check the connection cache and perform the node status
lookup only if the IP is not found to be bad */
@@ -206,71 +206,12 @@ BOOL get_dc_name(const char *domain, fstring srv_name, struct in_addr *ip_out)
}
}
- if ( !list_ordered )
- {
- /*
- * Pick a nice close server. Look for DC on local net
- * (assuming we don't have a list of preferred DC's)
- */
-
- for (i = 0; i < count; i++) {
- if (is_zero_ip(ip_list[i]))
- continue;
-
- if ( !is_local_net(ip_list[i]) )
- continue;
-
- if (name_status_find(domain, 0x1c, 0x20, ip_list[i], srv_name)) {
- result = check_negative_conn_cache( domain, srv_name );
- if ( NT_STATUS_IS_OK(result) ) {
- dc_ip = ip_list[i];
- goto done;
- }
- }
-
- zero_ip(&ip_list[i]);
- }
-
- /*
- * Try looking in the name status cache for an
- * entry we already have. We know that already
- * resolved ok.
- */
-
- for (i = 0; i < count; i++) {
- if (is_zero_ip(ip_list[i]))
- continue;
-
- if (namecache_status_fetch(domain, 0x1c, 0x20,
- ip_list[i], srv_name)) {
- result = check_negative_conn_cache( domain, srv_name );
- if ( NT_STATUS_IS_OK(result) ) {
- dc_ip = ip_list[i];
- goto done;
- }
- }
- }
-
- /*
- * Secondly try and contact a random PDC/BDC.
- */
-
- i = (sys_random() % count);
-
- if ( !is_zero_ip(ip_list[i]) ) {
- if ( name_status_find(domain, 0x1c, 0x20, ip_list[i], srv_name)) {
- result = check_negative_conn_cache( domain, srv_name );
- if ( NT_STATUS_IS_OK(result) ) {
- dc_ip = ip_list[i];
- goto done;
- }
- }
- zero_ip(&ip_list[i]); /* Tried and failed. */
- }
+ /* Pick a nice close server, but only if the list was not ordered */
+
+ if (!list_ordered && (count > 1) ) {
+ qsort(ip_list, count, sizeof(struct in_addr), QSORT_CAST ip_compare);
}
- /* Finally return first DC that we can contact */
-
for (i = 0; i < count; i++) {
if (is_zero_ip(ip_list[i]))
continue;
@@ -281,8 +222,9 @@ BOOL get_dc_name(const char *domain, fstring srv_name, struct in_addr *ip_out)
dc_ip = ip_list[i];
goto done;
}
- }
+ }
}
+
SAFE_FREE(ip_list);
@@ -295,7 +237,7 @@ BOOL get_dc_name(const char *domain, fstring srv_name, struct in_addr *ip_out)
the DC is alive and kicking. If we can catch a dead DC before
performing a cli_connect() we can avoid a 30-second timeout. */
- DEBUG(3, ("get_dc_name: Returning DC %s (%s) for domain %s\n", srv_name,
+ DEBUG(3, ("rpc_dc_name: Returning DC %s (%s) for domain %s\n", srv_name,
inet_ntoa(dc_ip), domain));
*ip_out = dc_ip;