forked from extern/egroupware
keeping only info about the connected ldap server, fixes problems with changed ldap host after fallback to other server
This commit is contained in:
parent
6d594d970c
commit
8bd0e2865d
@ -28,7 +28,9 @@ class ldap
|
|||||||
var $ds;
|
var $ds;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array $ldapServerInfo holds the detected information about the different ldap servers
|
* Holds the detected information about the connected ldap server
|
||||||
|
*
|
||||||
|
* @var ldapserverinfo
|
||||||
*/
|
*/
|
||||||
var $ldapServerInfo;
|
var $ldapServerInfo;
|
||||||
|
|
||||||
@ -41,21 +43,13 @@ class ldap
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* escapes a string for use in searchfilters meant for ldap_search.
|
* Returns information about connected ldap server
|
||||||
*
|
*
|
||||||
* Escaped Characters are: '*', '(', ')', ' ', '\', NUL
|
* @return ldapserverinfo|null
|
||||||
* It's actually a PHP-Bug, that we have to escape space.
|
|
||||||
* For all other Characters, refer to RFC2254.
|
|
||||||
* @param $string either a string to be escaped, or an array of values to be escaped
|
|
||||||
* @return ldapserverinfo|boolean
|
|
||||||
*/
|
*/
|
||||||
function getLDAPServerInfo($_host)
|
function getLDAPServerInfo()
|
||||||
{
|
{
|
||||||
if($this->ldapServerInfo[$_host] instanceof ldapserverinfo)
|
return $this->ldapServerInfo;
|
||||||
{
|
|
||||||
return $this->ldapServerInfo[$_host];
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -130,8 +124,6 @@ class ldap
|
|||||||
{
|
{
|
||||||
if ($h !== $host)
|
if ($h !== $host)
|
||||||
{
|
{
|
||||||
$this->ldapServerInfo[$host] =& $this->ldapServerInfo[$h];
|
|
||||||
|
|
||||||
if (isset($_SESSION)) // store working host as first choice in session
|
if (isset($_SESSION)) // store working host as first choice in session
|
||||||
{
|
{
|
||||||
$_SESSION['ldapConnect'][$host] = implode(' ',array_unique(array_merge(array($h),$hosts)));
|
$_SESSION['ldapConnect'][$host] = implode(' ',array_unique(array_merge(array($h),$hosts)));
|
||||||
@ -181,7 +173,9 @@ class ldap
|
|||||||
}
|
}
|
||||||
if ($use_tls) ldap_start_tls($this->ds);
|
if ($use_tls) ldap_start_tls($this->ds);
|
||||||
|
|
||||||
if(!isset($this->ldapServerInfo[$host]))
|
if (!isset($this->ldapServerInfo) ||
|
||||||
|
!is_a($this->ldapServerInfo,'ldapserverinfo') ||
|
||||||
|
$this->ldapServerInfo->host != $host)
|
||||||
{
|
{
|
||||||
//error_log("no ldap server info found");
|
//error_log("no ldap server info found");
|
||||||
$ldapbind = @ldap_bind($this->ds, $GLOBALS['egw_info']['server']['ldap_root_dn'], $GLOBALS['egw_info']['server']['ldap_root_pw']);
|
$ldapbind = @ldap_bind($this->ds, $GLOBALS['egw_info']['server']['ldap_root_dn'], $GLOBALS['egw_info']['server']['ldap_root_pw']);
|
||||||
@ -193,9 +187,9 @@ class ldap
|
|||||||
{
|
{
|
||||||
if($info = ldap_get_entries($this->ds, $sr))
|
if($info = ldap_get_entries($this->ds, $sr))
|
||||||
{
|
{
|
||||||
$ldapServerInfo = new ldapserverinfo();
|
$this->ldapServerInfo = new ldapserverinfo($host);
|
||||||
|
|
||||||
$ldapServerInfo->setVersion($supportedLDAPVersion);
|
$this->ldapServerInfo->setVersion($supportedLDAPVersion);
|
||||||
|
|
||||||
// check for naming contexts
|
// check for naming contexts
|
||||||
if($info[0]['namingcontexts'])
|
if($info[0]['namingcontexts'])
|
||||||
@ -204,7 +198,7 @@ class ldap
|
|||||||
{
|
{
|
||||||
$namingcontexts[] = $info[0]['namingcontexts'][$i];
|
$namingcontexts[] = $info[0]['namingcontexts'][$i];
|
||||||
}
|
}
|
||||||
$ldapServerInfo->setNamingContexts($namingcontexts);
|
$this->ldapServerInfo->setNamingContexts($namingcontexts);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for ldap server type
|
// check for ldap server type
|
||||||
@ -219,14 +213,14 @@ class ldap
|
|||||||
$ldapServerType = UNKNOWN_LDAPSERVER;
|
$ldapServerType = UNKNOWN_LDAPSERVER;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$ldapServerInfo->setServerType($ldapServerType);
|
$this->ldapServerInfo->setServerType($ldapServerType);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for subschema entry dn
|
// check for subschema entry dn
|
||||||
if($info[0]['subschemasubentry'])
|
if($info[0]['subschemasubentry'])
|
||||||
{
|
{
|
||||||
$subschemasubentry = $info[0]['subschemasubentry'][0];
|
$subschemasubentry = $info[0]['subschemasubentry'][0];
|
||||||
$ldapServerInfo->setSubSchemaEntry($subschemasubentry);
|
$this->ldapServerInfo->setSubSchemaEntry($subschemasubentry);
|
||||||
}
|
}
|
||||||
|
|
||||||
// create list of supported objetclasses
|
// create list of supported objetclasses
|
||||||
@ -252,24 +246,19 @@ class ldap
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$ldapServerInfo->setSupportedObjectClasses($supportedObjectClasses);
|
$this->ldapServerInfo->setSupportedObjectClasses($supportedObjectClasses);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->ldapServerInfo[$host] = $ldapServerInfo;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->ldapServerInfo[$host] = false;
|
unset($this->ldapServerInfo);
|
||||||
}
|
}
|
||||||
$this->saveSessionData();
|
$this->saveSessionData();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
$ldapServerInfo = $this->ldapServerInfo[$host];
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!@ldap_bind($this->ds, $dn, $passwd))
|
if(!@ldap_bind($this->ds, $dn, $passwd))
|
||||||
{
|
{
|
||||||
@ -293,6 +282,8 @@ class ldap
|
|||||||
if(is_resource($this->ds))
|
if(is_resource($this->ds))
|
||||||
{
|
{
|
||||||
ldap_unbind($this->ds);
|
ldap_unbind($this->ds);
|
||||||
|
unset($this->ds);
|
||||||
|
unset($this->ldapServerInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,6 +49,23 @@ class ldapserverinfo
|
|||||||
*/
|
*/
|
||||||
var $supportedOIDs = array();
|
var $supportedOIDs = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of host
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
var $host;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param string $host
|
||||||
|
*/
|
||||||
|
function __construct($host)
|
||||||
|
{
|
||||||
|
$this->host = $host;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gets the version
|
* gets the version
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user