LDAP: check if php-ldap is installed. If not, give an error output. FIX: blank Users page when the module is not installed.

This commit is contained in:
Arthur Schiwon 2012-07-25 18:40:48 +02:00
parent d17eb2983f
commit b94631de0c
2 changed files with 14 additions and 0 deletions

View File

@ -48,6 +48,10 @@ abstract class Access {
return false;
}
$cr = $this->connection->getConnectionResource();
if(!is_resource($cr)) {
//LDAP not available
return false;
}
$rr = @ldap_read($cr, $dn, 'objectClass=*', array($attr));
if(!is_resource($rr)) {
\OCP\Util::writeLog('user_ldap', 'readAttribute failed for DN '.$dn, \OCP\Util::DEBUG);

View File

@ -211,11 +211,21 @@ class Connection {
* Connects and Binds to LDAP
*/
private function establishConnection() {
static $phpLDAPinstalled = true;
if(!$phpLDAPinstalled) {
return false;
}
if(!$this->configured) {
\OCP\Util::writeLog('user_ldap', 'Configuration is invalid, cannot connect', \OCP\Util::WARN);
return false;
}
if(!$this->ldapConnectionRes) {
if(!function_exists('ldap_connect')) {
$phpLDAPinstalled = false;
\OCP\Util::writeLog('user_ldap', 'function ldap_connect is not available. Make sure that the PHP ldap module is installed.', \OCP\Util::ERROR);
return false;
}
$this->ldapConnectionRes = ldap_connect($this->config['ldapHost'], $this->config['ldapPort']);
if(ldap_set_option($this->ldapConnectionRes, LDAP_OPT_PROTOCOL_VERSION, 3)) {
if(ldap_set_option($this->ldapConnectionRes, LDAP_OPT_REFERRALS, 0)) {