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:
parent
d17eb2983f
commit
b94631de0c
|
@ -48,6 +48,10 @@ abstract class Access {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$cr = $this->connection->getConnectionResource();
|
$cr = $this->connection->getConnectionResource();
|
||||||
|
if(!is_resource($cr)) {
|
||||||
|
//LDAP not available
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$rr = @ldap_read($cr, $dn, 'objectClass=*', array($attr));
|
$rr = @ldap_read($cr, $dn, 'objectClass=*', array($attr));
|
||||||
if(!is_resource($rr)) {
|
if(!is_resource($rr)) {
|
||||||
\OCP\Util::writeLog('user_ldap', 'readAttribute failed for DN '.$dn, \OCP\Util::DEBUG);
|
\OCP\Util::writeLog('user_ldap', 'readAttribute failed for DN '.$dn, \OCP\Util::DEBUG);
|
||||||
|
|
|
@ -211,11 +211,21 @@ class Connection {
|
||||||
* Connects and Binds to LDAP
|
* Connects and Binds to LDAP
|
||||||
*/
|
*/
|
||||||
private function establishConnection() {
|
private function establishConnection() {
|
||||||
|
static $phpLDAPinstalled = true;
|
||||||
|
if(!$phpLDAPinstalled) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if(!$this->configured) {
|
if(!$this->configured) {
|
||||||
\OCP\Util::writeLog('user_ldap', 'Configuration is invalid, cannot connect', \OCP\Util::WARN);
|
\OCP\Util::writeLog('user_ldap', 'Configuration is invalid, cannot connect', \OCP\Util::WARN);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(!$this->ldapConnectionRes) {
|
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']);
|
$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_PROTOCOL_VERSION, 3)) {
|
||||||
if(ldap_set_option($this->ldapConnectionRes, LDAP_OPT_REFERRALS, 0)) {
|
if(ldap_set_option($this->ldapConnectionRes, LDAP_OPT_REFERRALS, 0)) {
|
||||||
|
|
Loading…
Reference in New Issue