Skip to content

Commit

Permalink
fix(ldap): if ldap server not defined (dn == '') returns a UserNotFou…
Browse files Browse the repository at this point in the history
…ndException (not a Symfony\Component\Ldap\Adapter\ExtLdap\ConnectionException)
  • Loading branch information
theus77 committed Dec 26, 2023
1 parent 0e83cfc commit 1898374
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions EMS/core-bundle/src/Security/Ldap/LdapUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Symfony\Component\Ldap\Security\LdapUser;
use Symfony\Component\Ldap\Security\LdapUserProvider as SymfonyLdapUserProvider;
use Symfony\Component\Security\Core\Exception\UserNotFoundException;
use Symfony\Component\Security\Core\User\UserInterface;

class LdapUserProvider extends SymfonyLdapUserProvider
{
Expand Down Expand Up @@ -41,4 +42,13 @@ protected function loadUser(string $identifier, Entry $entry): User

return $user ?: LdapCoreUserFactory::create($ldapUser, $this->ldapConfig);
}

public function loadUserByIdentifier(string $identifier): UserInterface
{
if ('' === $this->ldapConfig->baseDn) {
throw new UserNotFoundException(\sprintf('Ldap server not configured'));
}

return parent::loadUserByIdentifier($identifier);
}
}

0 comments on commit 1898374

Please sign in to comment.