Ejemplo n.º 1
0
 private function anonymousSearch($username)
 {
     $this->ldapManager->exists($username);
     $lm = $this->ldapManager->setUsername($username)->doPass();
     $ldapUser = new $this->userClass();
     $ldapUser->setUsername($lm->getUsername())->setEmail($lm->getEmail())->setRoles($lm->getRoles())->setDn($lm->getDn())->setCn($lm->getCn())->setAttributes($lm->getAttributes())->setGivenName($lm->getGivenName())->setSurname($lm->getSurname())->setDisplayName($lm->getDisplayName());
     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;
 }