|
|
@@ -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
|