|
@@ -133,24 +133,18 @@ class LDAPAuth {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (!$bind_result) {
|
|
if (!$bind_result) {
|
|
|
- $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);
|
|
|
|
|
|
|
+ throw new Exception('LDAP bind failed');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Test search
|
|
// Test search
|
|
|
$search = ldap_search($this->connection, $this->config['base_dn'], '(objectClass=*)', ['dn']);
|
|
$search = ldap_search($this->connection, $this->config['base_dn'], '(objectClass=*)', ['dn']);
|
|
|
if (!$search) {
|
|
if (!$search) {
|
|
|
- $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);
|
|
|
|
|
|
|
+ throw new Exception('LDAP search failed');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
return true;
|
|
|
|
|
|
|
|
} catch (Exception $e) {
|
|
} catch (Exception $e) {
|
|
|
- $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;
|
|
return false;
|
|
|
} finally {
|
|
} finally {
|
|
|
$this->disconnect();
|
|
$this->disconnect();
|
|
@@ -164,9 +158,7 @@ class LDAPAuth {
|
|
|
$this->connection = @ldap_connect($connection_string);
|
|
$this->connection = @ldap_connect($connection_string);
|
|
|
|
|
|
|
|
if (!$this->connection) {
|
|
if (!$this->connection) {
|
|
|
- $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);
|
|
|
|
|
|
|
+ throw new Exception('Failed to connect to LDAP server');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Set LDAP options
|
|
// Set LDAP options
|
|
@@ -230,7 +222,10 @@ class LDAPAuth {
|
|
|
throw new Exception('LDAP search failed');
|
|
throw new Exception('LDAP search failed');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- ldap_control_paged_result($this->connection, $limit);
|
|
|
|
|
|
|
+ // Use pagination for large result sets
|
|
|
|
|
+if (function_exists('ldap_control_paged_result')) {
|
|
|
|
|
+ ldap_control_paged_result($this->connection, $limit);
|
|
|
|
|
+}
|
|
|
$entries = ldap_get_entries($this->connection, $search);
|
|
$entries = ldap_get_entries($this->connection, $search);
|
|
|
|
|
|
|
|
$users = [];
|
|
$users = [];
|