]> source.dussan.org Git - nextcloud-server.git/commitdiff
group ldap: check configuration
authorArthur Schiwon <blizzz@owncloud.com>
Mon, 16 Apr 2012 15:28:58 +0000 (17:28 +0200)
committerArthur Schiwon <blizzz@owncloud.com>
Mon, 16 Apr 2012 15:28:58 +0000 (17:28 +0200)
apps/user_ldap/lib_ldap.php

index be85c5debe15808bf57ef495f8554431f04c718d..eb6a7214c1cd6212815600734182d12953cf7dea 100644 (file)
@@ -144,8 +144,19 @@ class OC_LDAP {
                        self::$ldapNoCase          = OC_Appconfig::getValue('user_ldap', 'ldap_nocase', 0);
                        self::$ldapUserDisplayName = OC_Appconfig::getValue('user_ldap', 'ldap_display_name', OC_USER_BACKEND_LDAP_DEFAULT_DISPLAY_NAME);
 
-                       //TODO: sanity checking
-                       self::$configured = true;
+                       if(
+                                  !empty(self::$ldapHost)
+                               && !empty(self::$ldapPort)
+                               && (
+                                          (!empty(self::$ldapAgentName) && !empty(self::$ldapAgentPassword))
+                                       || ( empty(self::$ldapAgentName) &&  empty(self::$ldapAgentPassword))
+                               )
+                               && !empty(self::$ldapBase)
+                               && !empty(self::$ldapUserDisplayName)
+                       )
+                       {
+                               self::$configured = true;
+                       }
                }
        }
 
@@ -153,6 +164,9 @@ class OC_LDAP {
         * Connects and Binds to LDAP
         */
        static private function establishConnection() {
+               if(!self::$configured) {
+                       return false;
+               }
                if(!self::$ldapConnectionRes) {
                        self::$ldapConnectionRes = ldap_connect(self::$ldapHost, self::$ldapPort);
                        if(ldap_set_option(self::$ldapConnectionRes, LDAP_OPT_PROTOCOL_VERSION, 3)) {