public function authenticate(TokenInterface $token) { $user = $this->userProvider->loadUserByUsername($token->getUsername()); if ($this->bind($user, $token)) { $ldapToken = new LdapToken($user, '', $user->getRoles()); $ldapToken->setAuthenticated(true); $ldapToken->setAttributes($token->getAttributes()); return $ldapToken; } throw new AuthenticationException('The LDAP authentication failed.'); }
/** * {@inheritdoc} */ public function authenticate(TokenInterface $token) { if (!$this->supports($token)) { throw new AuthenticationException('Unsupported token'); } try { $user = $this->userProvider->loadUserByUsername($token->getUsername()); } catch (UsernameNotFoundException $userNotFoundException) { if (!$this->hideUserNotFoundExceptions) { throw new BadCredentialsException('Bad credentials', 0, $userNotFoundException); } throw $userNotFoundException; } if ($this->bind($user, $token)) { $ldapToken = new LdapToken($user, '', $user->getRoles()); $ldapToken->setAuthenticated(true); return $ldapToken; } throw new AuthenticationException('The LDAP authentication failed.'); }