fixed some problems:

- in setup we have no sessions --> query the infos on each request
- if the server allows no version 2 binds, the class failed. Now we try again with version 3 set (and succeed)
This commit is contained in:
Ralf Becker 2006-06-07 22:58:11 +00:00
parent 02cfb662e8
commit 1934c4ce6d

View File

@ -97,7 +97,6 @@
printf('<b>Error: LDAP support unavailable</b><br>',$host); printf('<b>Error: LDAP support unavailable</b><br>',$host);
return False; return False;
} }
if(!$host) if(!$host)
{ {
$host = $GLOBALS['egw_info']['server']['ldap_host']; $host = $GLOBALS['egw_info']['server']['ldap_host'];
@ -130,7 +129,12 @@
if(!isset($this->ldapServerInfo[$host])) { if(!isset($this->ldapServerInfo[$host])) {
//print "no ldap server info found<br>"; //print "no ldap server info found<br>";
if (!($ldapbind = @ldap_bind($this->ds, '', '')))
{
// try with version 3 ;-)
ldap_set_option($this->ds, LDAP_OPT_PROTOCOL_VERSION, 3);
$ldapbind = ldap_bind($this->ds, '', ''); $ldapbind = ldap_bind($this->ds, '', '');
}
$filter='(objectclass=*)'; $filter='(objectclass=*)';
$justthese = array('structuralObjectClass','namingContexts','supportedLDAPVersion','subschemaSubentry'); $justthese = array('structuralObjectClass','namingContexts','supportedLDAPVersion','subschemaSubentry');
@ -228,8 +232,10 @@
/** /**
* disconnect from the ldap server * disconnect from the ldap server
*/ */
function ldapDisconnect() { function ldapDisconnect()
if(is_resource($this->ds)) { {
if(is_resource($this->ds))
{
ldap_unbind($this->ds); ldap_unbind($this->ds);
} }
} }
@ -237,15 +243,23 @@
/** /**
* restore the session data * restore the session data
*/ */
function restoreSessionData() { function restoreSessionData()
{
if (is_object($GLOBALS['egw']->session)) // no availible in setup
{
$this->ldapServerInfo = $GLOBALS['egw']->session->appsession('ldapServerInfo'); $this->ldapServerInfo = $GLOBALS['egw']->session->appsession('ldapServerInfo');
} }
}
/** /**
* save the session data * save the session data
*/ */
function saveSessionData() { function saveSessionData()
{
if (is_object($GLOBALS['egw']->session)) // no availible in setup
{
$GLOBALS['egw']->session->appsession('ldapServerInfo','',$this->ldapServerInfo); $GLOBALS['egw']->session->appsession('ldapServerInfo','',$this->ldapServerInfo);
} }
}
} }
?> ?>