Authenticate the given username and password with LDAP.

@param string $username
@param string $password

@return array
198764
public function authenticate($username, $password)
    {
        $result = $this->getGateway()->authenticate($username, $password);
        $messages = $result->getMessages();

        // all messages beyond the first one are for debugging and
        // not suitable to display to the user.
        foreach ($messages as $i => $message) {
            if ($i > 0) {
                $this->getLogger()->debug(str_replace("\n", "\n  ", $message));
            }
        }

        $message = $messages[0]; // first message is user readable, suitable for showing on login form

        // show better errors than the defaults for various status codes returned by LDAP
        if (!empty($messages[1]) && strpos($messages[1], 'NT_STATUS_ACCOUNT_LOCKED_OUT') !== false) {
            $message = _t(
                __CLASS__ . '.ACCOUNTLOCKEDOUT',
                'Your account has been temporarily locked because of too many failed login attempts. ' .
                'Please try again later.'
            );
        }
        if (!empty($messages[1]) && strpos($messages[1], 'NT_STATUS_LOGON_FAILURE') !== false) {
            $message = _t(
                __CLASS__ . '.INVALIDCREDENTIALS',
                'The provided details don\'t seem to be correct. Please try again.'
            );
        }

        return [
            'success' => $result->getCode() === 1,
            'identity' => $result->getIdentity(),
            'message' => $message,
            'code' => $result->getCode()
        ];
    }
346747
public function authenticateUser($username)
    {
        if ($username)
        {
            $user = $this->userManager->findUserBy(['username' => $username]);

            if ($user)
            {
                $usernamePasswordToken = new UsernamePasswordToken($user->getUsername(), $user->getPlainPassword(), 'default', $user->getRoles());
                $this->tokenStorage->setToken($usernamePasswordToken);

                return $user;
            }
        }
        return false;
    }
464767
protected function authenticate($username,$password) {

            if (is_callable($this->onAuthenticate)) {
                call_user_func($this->onAuthenticate,$username,$password);
            }

        }
892064
public function authCredentials(string $username, string $password): self
    {
        $this->username = $username;
        $this->password = $password;
        return $this;
    }
742296
public function login(?string $username, ?string $password)
    {
        try {
            $this->startBrokerSession();

            if (!$username || !$password) {
                $this->fail('No username and/or password provided.');
            }

            if (!$this->authenticate($username, $password)) {
                $this->fail('User authentication failed.');
            }
        } catch (SSOServerException $e) {
            return $this->returnJson(['error' => $e->getMessage()]);
        }

        $this->setSessionData('sso_user', $username);

        return $this->userInfo();
    }
761506
public function checkUserCredentials($username, $password)
    {
        if ($user = $this->getUser($username)) {
            return $this->checkPassword($user, $password);
        }

        return false;
    }
277073
public function checkUserCredentials($username, $password)
    {
        $userDetails = $this->getUserDetails($username);

        return $userDetails && $userDetails['password'] && $userDetails['password'] === $password;
    }
1257136
public function ldap_bind($ldap, $dn = NULL, $password = NULL)
	{
		return \ldap_bind($ldap, $dn, $password);
	}
67862
protected function getApiResponseAuthToken($username, $password)
    {
        $response = $this->sendRequest('GET', sprintf(
            self::API_AUTH_URL,
            urlencode($username),
            urlencode($password)
        ));

        return $response->getBody()->getContents();
    }
1011908
public function authenticate($username, $password)
    {
        if ($user = $this->find($username)) {
            if ($user->account) {
                if ($this->passwordVerify($password, $user->account->password)) {
                    if ($this->passwordRehash($password)) {
                        $user->account->update([
                            'id'       => $user->id,
                            'password' => $this->passwordHash($password),
                        ]);
                    }

                    $account = $user->account->getArrayCopy();
                }
            } elseif ($this->passwordVerify($password, $user->password)) {
                $account = $user->getArrayCopy();
            }

            if (isset($account)) {
                foreach ($account as $key => $value) {
                    if (strpos($key, 'record') !== false) {
                        unset($account[ $key ]);
                    } elseif (in_array($key,
                        ['password', 'pin', 'token', 'sso', 'id_sys_user', 'id_sys_module', 'id_sys_module_role'])) {
                        unset($account[ $key ]);
                    }
                }

                $this->login($account);

                return true;
            }
        }

        return false;
    }
139925
public function authenticate($username, $password) {

    // Get some things.
    $client = $this->getClient();
    $parameters = $this->getAuthParams();
    $endpoint = $this->getEndpoint();
    $code = NULL;

    $response = $client->get($endpoint,
      ['query' => $parameters, 'auth' => [$username, $password]]
    );

    $code = $response->getStatusCode();
    $this->setLastResponse($response);

    // @todo: handle non 200 responses with error logging.
    switch ($code) {
      case '200':
        $body = $response->getBody();
        $json = json_decode($body->getContents());
        if (empty($json)) {
          throw new \Exception("Could not get JSON from body.");
        }
        $this->setAuthApiToken($json->access_token);
        $this->setAuthApiTokenExpires($json->expires_in);
        break;
    }

    return $this;
  }
933669
public function setHttpAuth(string $username, string $password = ''): AbstractApi
    {
        $this->httpAuth['username'] = $username;
        $this->httpAuth['password'] = $password;

        return $this;
    }
294278
public function authenticate($username, $password)
	{
		$this->debug->groupCollapsed(__METHOD__);
		$return = false;
		$users = $this->search(array(
			'username'	=> $username,
			'email'		=> $username,
		));
		if ($users && $this->verifyPassword($password, $users[0]['password'])) {
			$this->debug->info('login success');
			$this->log('login', $users[0]['userid']);
			$return = $users[0]['userid'];
		} else {
			$this->debug->warn('login failed');
			$userid = $users
				? $users[0]['userid']
				: null;
			$this->log('loginFail', $userid);
		}
		$this->debug->groupEnd();
		return $return;
	}
849428
public function basicAuth($username, $password)
    {
        $this->username = $username;
        $this->password = $password;
        return $this;
    }
89929
public function login($username, $password) {
  $query = new \Peyote\Select('users');
  $query->where('username', '=', $username)
        ->limit(1);
  $userdata = $this->db->fetch($query);
  if (!isset($userdata[0])) throw new \Exception('User not found');
  $userdata = $userdata[0];
  $pwhash = $this->passhash($password,$userdata['salt']);
  if ($pwhash != $userdata['password']) throw new \JohnVanOrange\Core\Exception\Invalid('Invalid password');
  //succesfully login
  $sid = $this->getSecureID();
  $this->setCookie('sid', $sid);
  $query = new \Peyote\Insert('sessions');
  $query->columns(['user_id', 'sid', 'last_access'])
        ->values([$userdata['id'],$sid, date('Y-m-d H:i:s')]);
  $this->db->fetch($query);
  //update last access for in user table
  $query = new \Peyote\Update('users');
  $query->set([
               'last_login' => date('Y-m-d H:i:s')
              ])
        ->where('username', '=', $username);
  $this->db->fetch($query);
  return array(
   'message' => 'Login successful',
   'sid' => $sid
  );
 }
403702
public function authenticate($username, $password, $tenantName)
	{
		$command = $this->identityClient->getCommand('Authenticate');
		$command->setUsername($username)->setPassword($password)->setTenantname(
			$tenantName
		);
		try {
			$authResult = $command->execute()->getResult;
			$this->username = $username;
			$this->password = $password;
			$this->tenantName = $tenantName;

			//Copy Service Catalog
			$this->serviceCatalog = $authResult['access']['serviceCatalog'];

			//Get token
			$this->token = $authResult['access']['token'];

			//Default Region
			$this->region = 'RegionOne';
		} catch (OpenstackException $e) {

		}
	}
624042
private function bindUsingCredentials($username, $password)
    {
        // Allow binding with null credentials
        if (empty($username)) {
            $username = null;
        } else {
            $username .= $this->getAccountSuffix();
        }

        if (empty($password)) {
            $password = null;
        }

        $this->ldapConnection->bind($username, $password);

        if (!$this->ldapConnection->isBound()) {
            $error = $this->ldapConnection->getLastError();

            if ($this->ldapConnection->isUsingSSL() && !$this->ldapConnection->isUsingTLS()) {
                $message = 'Bind to Active Directory failed. Either the LDAPs connection failed or the login credentials are incorrect. AD said: '.$error;
            } else {
                $message = 'Bind to Active Directory failed. Check the login credentials and/or server details. AD said: '.$error;
            }

            throw new AdldapException($message);
        }

        return true;
    }