/** * 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); }
/** * 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); }