summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2012-07-25 18:21:16 +0200
committerArthur Schiwon <blizzz@owncloud.com>2012-07-25 18:21:16 +0200
commit3c9919e475484e6c25536fc006c7039d1576d350 (patch)
treecb2713d634a61adaba465a5d7c701fc4f194ae54
parent9b0870bb91d35b20903a8c23d1348c7beddf8bf8 (diff)
downloadnextcloud-server-3c9919e475484e6c25536fc006c7039d1576d350.tar.gz
nextcloud-server-3c9919e475484e6c25536fc006c7039d1576d350.zip
LDAP: check if php-ldap is installed. If not, give an error output. FIX: blank Users page when the module is not installed.
-rw-r--r--apps/user_ldap/lib_ldap.php20
1 files changed, 20 insertions, 0 deletions
diff --git a/apps/user_ldap/lib_ldap.php b/apps/user_ldap/lib_ldap.php
index f3b0b993cea..39992e81e05 100644
--- a/apps/user_ldap/lib_ldap.php
+++ b/apps/user_ldap/lib_ldap.php
@@ -440,6 +440,10 @@ class OC_LDAP {
*/
static public function readAttribute($dn, $attr) {
$cr = self::getConnectionResource();
+ if(!is_resource($cr)) {
+ //LDAP not available
+ return false;
+ }
$rr = ldap_read($cr, $dn, 'objectClass=*', array($attr));
$er = ldap_first_entry($cr, $rr);
//LDAP attributes are not case sensitive
@@ -495,6 +499,11 @@ class OC_LDAP {
if(!is_null($attr) && !is_array($attr)) {
$attr = array(strtolower($attr));
}
+ $cr = self::getConnectionResource();
+ if(!is_resource($cr)) {
+ //LDAP not available
+ return array();
+ }
$sr = @ldap_search(self::getConnectionResource(), $base, $filter, $attr);
$findings = @ldap_get_entries(self::getConnectionResource(), $sr );
// if we're here, probably no connection ressource is returned.
@@ -686,11 +695,22 @@ class OC_LDAP {
* Connects and Binds to LDAP
*/
static private function establishConnection() {
+ static $phpLDAPinstalled = true;
+ if(!$phpLDAPinstalled) {
+ return false;
+ }
if(!self::$configured) {
OCP\Util::writeLog('ldap', 'Configuration is invalid, cannot connect', OCP\Util::INFO);
return false;
}
if(!self::$ldapConnectionRes) {
+ //check if php-ldap is installed
+ 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;
+ }
self::$ldapConnectionRes = ldap_connect(self::$ldapHost, self::$ldapPort);
if(ldap_set_option(self::$ldapConnectionRes, LDAP_OPT_PROTOCOL_VERSION, 3)) {
if(ldap_set_option(self::$ldapConnectionRes, LDAP_OPT_REFERRALS, 0)) {