Ver código fonte

Fixes to LDAP integration

svalavuo 6 dias atrás
pai
commit
097982e639
3 arquivos alterados com 20 adições e 1 exclusões
  1. 11 0
      admin/login.php
  2. 3 1
      includes/ldap.php
  3. 6 0
      setup/setup.php

+ 11 - 0
admin/login.php

@@ -3,6 +3,17 @@ require_once '../includes/config.php';
 require_once '../includes/database.php';
 require_once '../includes/auth.php';
 
+// Start session for language preference
+session_start();
+
+// Initialize translation system
+try {
+    $translation = Translation::getInstance();
+} catch (Exception $e) {
+    // Fallback to basic translations if LDAP fails
+    $translation = null;
+}
+
 // Include LDAP class if LDAP is enabled
 if (LDAP_ENABLED) {
     require_once '../includes/ldap.php';

+ 3 - 1
includes/ldap.php

@@ -155,9 +155,11 @@ class LDAPAuth {
     private function connect() {
         $connection_string = $this->config['host'] . ':' . $this->config['port'];
         
-        $this->connection = ldap_connect($connection_string);
+        // Suppress LDAP warnings for cleaner error handling
+        $this->connection = @ldap_connect($connection_string);
         
         if (!$this->connection) {
+            error_log('LDAP Connection Error: Failed to connect to LDAP server');
             throw new Exception('Failed to connect to LDAP server');
         }
         

+ 6 - 0
setup/setup.php

@@ -64,6 +64,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
     if (empty($admin_email)) $errors[] = 'Admin email is required';
     if (!filter_var($admin_email, FILTER_VALIDATE_EMAIL)) $errors[] = 'Invalid email format';
     
+    // Language validation
+    if (!in_array($default_language, ['en', 'fi'])) {
+        $errors[] = 'Invalid language selection';
+        $default_language = 'en';
+    }
+    
     // If LDAP is disabled, require admin password
     if (!$ldap_enabled && empty($admin_password)) {
         $errors[] = 'Admin password is required when LDAP is disabled';