コード例 #1
0
 /**
  * Authenticate a user
  *
  * @param   string user
  * @param   string pass
  * @return  bool
  * @throws  security.auth.AuthenticatorException
  */
 public function authenticate($user, $pass)
 {
     if (!($crypt = $this->lookup($user))) {
         return false;
     }
     return UnixCrypt::matches($crypt, $pass);
 }
コード例 #2
0
 /**
  * Authenticate a user
  *
  * @param   string user
  * @param   string pass
  * @return  bool
  */
 public function authenticate($user, $pass)
 {
     try {
         $r = $this->lc->search($this->basedn, '(uid=' . $user . ')');
     } catch (LDAPException $e) {
         throw new AuthenticatorException(sprintf('Authentication failed (#%d: "%s")', $e->getErrorCode(), $e->getMessage()), $e);
     } catch (ConnectException $e) {
         throw new AuthenticatorException(sprintf('Authentication failed (<connect>: "%s")', $e->getMessage()), $e);
     }
     // Check return, we must find a distinct user
     if (1 != $r->numEntries()) {
         return false;
     }
     $entry = $r->getNextEntry();
     return UnixCrypt::matches($entry->getAttribute('userpassword', 0), $pass);
 }