Security/Authentication/Provider/LdapAuthenticationProvider.php
public function authenticate(TokenInterface $token)
    {
        $domain = $this->ldap->getDomainContext();

        try {
            $this->switchDomainIfNeeded($this->getDomainFromToken($token));
            $this->setLdapCredentialsIfNeeded($token->getUsername(), $token->getCredentials(), $this->userProvider);
            $user = $this->userProvider->loadUserByUsername($token->getUsername());
            $this->userChecker->checkPreAuth($user);
            $token = $this->doAuthentication($user, $token);
            $this->userChecker->checkPostAuth($user);
        } catch (UsernameNotFoundException $e) {
            $this->hideOrThrow($e, $this->hideUserNotFoundExceptions);
        } catch (BadCredentialsException $e) {
            $this->hideOrThrow($e, $this->hideUserNotFoundExceptions);
        } catch (LdapConnectionException $e) {
            $this->hideOrThrow($e, $this->hideUserNotFoundExceptions);
        } finally {
            $this->switchDomainBackIfNeeded($domain);
        }

        return $token;
    }
public function authenticate(TokenInterface $token)
    {
        $domain = $this->ldap->getDomainContext();

        try {
            $this->switchDomainIfNeeded($this->getDomainFromToken($token));
            $this->setLdapCredentialsIfNeeded($token->getUsername(), $token->getCredentials(), $this->userProvider);
            $user = $this->userProvider->loadUserByUsername($token->getUsername());
            $this->userChecker->checkPreAuth($user);
            $token = $this->doAuthentication($user, $token);
            $this->userChecker->checkPostAuth($user);
        } catch (UsernameNotFoundException $e) {
            $this->hideOrThrow($e, $this->hideUserNotFoundExceptions);
        } catch (BadCredentialsException $e) {
            $this->hideOrThrow($e, $this->hideUserNotFoundExceptions);
        } catch (LdapConnectionException $e) {
            $this->hideOrThrow($e, $this->hideUserNotFoundExceptions);
        } finally {
            $this->switchDomainBackIfNeeded($domain);
        }

        return $token;
    }
{@inheritdoc}