1
0
mirror of https://github.com/samba-team/samba.git synced 2025-12-02 00:23:50 +03:00

r19651: Fix interesting bug with the automatic site coverage in Active Directory:

When having DC-less sites, AD assigns DCs from other sites to that site
that does not have it's own DC. The most reliable way for us to identify
the nearest DC - in that and all other cases - is the closest_dc flag in
the CLDAP reply.

Guenther
This commit is contained in:
Günther Deschner
2006-11-10 12:42:50 +00:00
committed by Gerald (Jerry) Carter
parent 1bc834455d
commit ff004f7284
4 changed files with 28 additions and 4 deletions

View File

@@ -139,6 +139,30 @@ BOOL ads_sitename_match(ADS_STRUCT *ads)
return False;
}
/**********************************************
Is this the closest DC ?
**********************************************/
BOOL ads_closest_dc(ADS_STRUCT *ads)
{
if (ads->config.flags & ADS_CLOSEST) {
DEBUG(10,("ads_closest_dc: ADS_CLOSEST flag set\n"));
return True;
}
/* not sure if this can ever happen */
if (ads_sitename_match(ads)) {
DEBUG(10,("ads_closest_dc: ADS_CLOSEST flag not set but sites match\n"));
return True;
}
DEBUG(10,("ads_closest_dc: %s is not the closest DC\n",
ads->config.ldap_server_name));
return False;
}
/*
try a connection to a given ldap server, returning True and setting the servers IP
in the ads struct if successful
@@ -392,7 +416,7 @@ got_connection:
}
/* cache the successful connection for workgroup and realm */
if (ads_sitename_match(ads)) {
if (ads_closest_dc(ads)) {
saf_store( ads->server.workgroup, inet_ntoa(ads->ldap_ip));
saf_store( ads->server.realm, inet_ntoa(ads->ldap_ip));
}