Explorar el Código

Fixes to LDAP integration

svalavuo hace 6 días
padre
commit
d588bc2e33
Se han modificado 1 ficheros con 11 adiciones y 5 borrados
  1. 11 5
      includes/ldap.php

+ 11 - 5
includes/ldap.php

@@ -133,19 +133,24 @@ class LDAPAuth {
             }
             
             if (!$bind_result) {
-                throw new Exception('LDAP bind failed');
+                $error = 'LDAP bind failed';
+                error_log("LDAP Connection Test Error: $error - Host: {$this->config['host']}, Port: {$this->config['port']}, Base DN: {$this->config['base_dn']}");
+                throw new Exception($error);
             }
             
             // Test search
             $search = ldap_search($this->connection, $this->config['base_dn'], '(objectClass=*)', ['dn']);
             if (!$search) {
-                throw new Exception('LDAP search failed');
+                $error = 'LDAP search failed';
+                error_log("LDAP Connection Test Error: $error - Host: {$this->config['host']}, Port: {$this->config['port']}, Base DN: {$this->config['base_dn']}");
+                throw new Exception($error);
             }
             
             return true;
             
         } catch (Exception $e) {
-            error_log('LDAP Connection Test Error: ' . $e->getMessage());
+            $error = 'Connection failed: ' . $e->getMessage();
+            error_log("LDAP Connection Test Error: $error - Host: {$this->config['host']}, Port: {$this->config['port']}, Base DN: {$this->config['base_dn']}");
             return false;
         } finally {
             $this->disconnect();
@@ -159,8 +164,9 @@ class LDAPAuth {
         $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');
+            $error = 'Failed to connect to LDAP server';
+            error_log("LDAP Connection Error: $error - Host: {$this->config['host']}, Port: {$this->config['port']}, Base DN: {$this->config['base_dn']}");
+            throw new Exception($error);
         }
         
         // Set LDAP options