Esempio n. 1
0
 public function loadUserByUsername($username)
 {
     if (!$this->ldapManager->exists($username)) {
         throw new UsernameNotFoundException(sprintf('User "%s" not found', $username));
     }
     $lm = $this->ldapManager->setUsername($username)->doPass();
     $ldapUser = new LdapUser();
     $ldapUser->setUsername($lm->getUsername())->setEmail($lm->getEmail())->setRoles($lm->getRoles())->setDn($lm->getDn());
     return $ldapUser;
 }
 /**
  * {@inheritdoc}
  */
 public function loadUserByUsername($username)
 {
     // Throw the exception if the username is not provided.
     if (empty($username)) {
         throw new UsernameNotFoundException('The username is not provided.');
     }
     // Throw the exception if the username is not found.
     if (!$this->ldapManager->exists($username)) {
         throw new UsernameNotFoundException(sprintf('User "%s" not found', $username));
     }
     $lm = $this->ldapManager->setUsername($username)->doPass();
     $ldapUser = new LdapUser();
     $ldapUser->setUsername($lm->getUsername())->setEmail($lm->getEmail())->setRoles($lm->getRoles())->setDn($lm->getDn())->setAttributes($lm->getAttributes());
     return $ldapUser;
 }