From 1934c4ce6d3d51081c8e56f25ffafc4132f75966 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 7 Jun 2006 22:58:11 +0000 Subject: [PATCH] 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) --- phpgwapi/inc/class.ldap.inc.php | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/phpgwapi/inc/class.ldap.inc.php b/phpgwapi/inc/class.ldap.inc.php index 96d12e90da..babfe92b43 100644 --- a/phpgwapi/inc/class.ldap.inc.php +++ b/phpgwapi/inc/class.ldap.inc.php @@ -97,7 +97,6 @@ printf('Error: LDAP support unavailable
',$host); return False; } - if(!$host) { $host = $GLOBALS['egw_info']['server']['ldap_host']; @@ -130,7 +129,12 @@ if(!isset($this->ldapServerInfo[$host])) { //print "no ldap server info found
"; - $ldapbind = ldap_bind($this->ds, '', ''); + 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, '', ''); + } $filter='(objectclass=*)'; $justthese = array('structuralObjectClass','namingContexts','supportedLDAPVersion','subschemaSubentry'); @@ -228,8 +232,10 @@ /** * disconnect from the ldap server */ - function ldapDisconnect() { - if(is_resource($this->ds)) { + function ldapDisconnect() + { + if(is_resource($this->ds)) + { ldap_unbind($this->ds); } } @@ -237,14 +243,22 @@ /** * restore the session data */ - function restoreSessionData() { - $this->ldapServerInfo = $GLOBALS['egw']->session->appsession('ldapServerInfo'); + function restoreSessionData() + { + if (is_object($GLOBALS['egw']->session)) // no availible in setup + { + $this->ldapServerInfo = $GLOBALS['egw']->session->appsession('ldapServerInfo'); + } } /** * save the session data */ - function saveSessionData() { - $GLOBALS['egw']->session->appsession('ldapServerInfo','',$this->ldapServerInfo); + function saveSessionData() + { + if (is_object($GLOBALS['egw']->session)) // no availible in setup + { + $GLOBALS['egw']->session->appsession('ldapServerInfo','',$this->ldapServerInfo); + } } }