]> source.dussan.org Git - nextcloud-server.git/commitdiff
LDAP: check if php-ldap is installed. If not, give an error output. FIX: blank Users...
authorArthur Schiwon <blizzz@owncloud.com>
Wed, 25 Jul 2012 16:21:16 +0000 (18:21 +0200)
committerArthur Schiwon <blizzz@owncloud.com>
Wed, 25 Jul 2012 16:21:16 +0000 (18:21 +0200)
apps/user_ldap/lib_ldap.php

index f3b0b993cea754bedbc7885f67b91f2af8393b4c..39992e81e0517064c0d63e6f52762ac4b3ae6806 100644 (file)
@@ -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)) {