summaryrefslogtreecommitdiff
path: root/source3/nsswitch/winbindd_rpc.c
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2003-06-25 17:41:05 +0000
committerGerald Carter <jerry@samba.org>2003-06-25 17:41:05 +0000
commitf51d769dd303027a3dbf46fc89a482933988e866 (patch)
tree5bb400a9df1f6fb27f2b045a6521e2995de8c686 /source3/nsswitch/winbindd_rpc.c
parenteb61c8238298e97644202139e6d7f55e46eb9c26 (diff)
downloadsamba-f51d769dd303027a3dbf46fc89a482933988e866.tar.gz
samba-f51d769dd303027a3dbf46fc89a482933988e866.tar.bz2
samba-f51d769dd303027a3dbf46fc89a482933988e866.zip
large change:
*) consolidates the dc location routines again (dns and netbios) get_dc_list() or get_sorted_dc_list() is the authoritative means of locating DC's again. (also inludes a flag to get_dc_list() to define if this should be a DNS only lookup or not) (however, if you set "name resolve order = hosts wins" you could still get DNS queries for domain name IFF ldap_domain2hostlist() fails. The answer? Fix your DNS setup) *) enabled DOMAIN<0x1c> lookups to be funneled through resolve_hosts resulting in a call to ldap_domain2hostlist() if lp_security() == SEC_ADS *) enables name cache for winbind ADS backend *) enable the negative connection cache for winbind ADS backend *) removes some old dead code *) consolidates some duplicate code *) moves the internal_name_resolve() to use an IP/port pair to deal with SRV RR dns replies. The namecache code also supports the IP:port syntax now as well. *) removes 'ads server' and moves the functionality back into 'password server' (which can support "hostname:port" syntax now but works fine with defaults depending on the value of lp_security()) (This used to be commit d7f7fcda425bef380441509734eca33da943c091)
Diffstat (limited to 'source3/nsswitch/winbindd_rpc.c')
-rw-r--r--source3/nsswitch/winbindd_rpc.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/source3/nsswitch/winbindd_rpc.c b/source3/nsswitch/winbindd_rpc.c
index 6436d4860c..81a79751f8 100644
--- a/source3/nsswitch/winbindd_rpc.c
+++ b/source3/nsswitch/winbindd_rpc.c
@@ -715,7 +715,7 @@ static LDAP *ldap_open_with_timeout(const char *server, int port, unsigned int t
return ldp;
}
-static int get_ldap_seq(const char *server, uint32 *seq)
+static int get_ldap_seq(const char *server, int port, uint32 *seq)
{
int ret = -1;
struct timeval to;
@@ -731,7 +731,7 @@ static int get_ldap_seq(const char *server, uint32 *seq)
* doesn't seem to apply to doing an open as well. JRA.
*/
- if ((ldp = ldap_open_with_timeout(server, LDAP_PORT, 10)) == NULL)
+ if ((ldp = ldap_open_with_timeout(server, port, 10)) == NULL)
return -1;
/* Timeout if no response within 20 seconds. */
@@ -770,36 +770,39 @@ static int get_ldap_seq(const char *server, uint32 *seq)
int get_ldap_sequence_number( const char* domain, uint32 *seq)
{
int ret = -1;
- int i;
- struct in_addr *ip_list = NULL;
+ int i, port = LDAP_PORT;
+ struct ip_service *ip_list = NULL;
int count;
- BOOL list_ordered;
- if ( !get_dc_list( domain, &ip_list, &count, &list_ordered ) ) {
+ if ( !get_sorted_dc_list(domain, &ip_list, &count, False) ) {
DEBUG(3, ("Could not look up dc's for domain %s\n", domain));
return False;
}
- /* sort the list so we can pick a close server */
-
- 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]))
+ fstring ipstr;
+
+ /* since the is an LDAP lookup, default to the LDAP_PORT is not set */
+ port = (ip_list[i].port!= PORT_NONE) ? ip_list[i].port : LDAP_PORT;
+
+ fstrcpy( ipstr, inet_ntoa(ip_list[i].ip) );
+
+ if (is_zero_ip(ip_list[i].ip))
continue;
- if ( (ret = get_ldap_seq( inet_ntoa(ip_list[i]), seq)) == 0 )
+ if ( (ret = get_ldap_seq( ipstr, port, seq)) == 0 )
goto done;
+
+ /* add to failed connection cache */
+ add_failed_connection_entry( domain, ipstr, NT_STATUS_UNSUCCESSFUL );
}
done:
if ( ret == 0 ) {
- DEBUG(3, ("get_ldap_sequence_number: Retrieved sequence number for Domain (%s) from DC (%s)\n",
- domain, inet_ntoa(ip_list[i])));
+ DEBUG(3, ("get_ldap_sequence_number: Retrieved sequence number for Domain (%s) from DC (%s:%d)\n",
+ domain, inet_ntoa(ip_list[i].ip), port));
}
SAFE_FREE(ip_list);