Skip to content

Commit

Permalink
fix: corrected error handling for LDAP, closes #3319
Browse files Browse the repository at this point in the history
  • Loading branch information
thorsten committed Jan 10, 2025
1 parent 4e156f9 commit dcdacad
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions phpmyfaq/src/phpMyFAQ/Ldap.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ public function bind(string $rdn = '', #[SensitiveParameter] string $password =
if ('' === $rdn && '' === $password) {
return ldap_bind($this->ds);
}

return ldap_bind($this->ds, $rdn, $password);
}

Expand All @@ -163,6 +164,7 @@ public function getMail(string $username): bool|string
*/
private function getLdapData(string $username, string $data): bool|string
{

if ($this->ds === false) {
$this->error = 'The LDAP connection handler is not a valid resource.';

Expand Down
2 changes: 1 addition & 1 deletion phpmyfaq/src/phpMyFAQ/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ public function getUserByLogin(string $login, bool $raiseError = true): bool
$result = $this->configuration->getDb()->query($select);
if ($this->configuration->getDb()->numRows($result) !== 1) {
if ($raiseError) {
throw new Core\Exception(self::ERROR_USER_INCORRECT_LOGIN);
$this->errors[] = self::ERROR_USER_INCORRECT_LOGIN;
}

return false;
Expand Down

0 comments on commit dcdacad

Please sign in to comment.