ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilAuthProviderDatabase.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once './Services/Authentication/classes/Provider/class.ilAuthProvider.php';
6 include_once './Services/Authentication/interfaces/interface.ilAuthProviderInterface.php';
7 
15 {
16 
17 
22  public function doAuthentication(ilAuthStatus $status)
23  {
24  include_once './Services/User/classes/class.ilUserPasswordManager.php';
25 
29  $user = ilObjectFactory::getInstanceByObjId(ilObjUser::_loginExists($this->getCredentials()->getUsername()),false);
30 
31  $this->getLogger()->debug('Trying to authenticate user: '. $this->getCredentials()->getUsername());
32  if($user instanceof ilObjUser)
33  {
34  if(!ilAuthUtils::isLocalPasswordEnabledForAuthMode($user->getAuthMode(true)))
35  {
36  $this->getLogger()->debug('DB authentication failed: current user auth mode does not allow local validation.');
37  $this->getLogger()->debug('User auth mode: ' . $user->getAuthMode(true));
38  $this->handleAuthenticationFail($status, 'err_wrong_login');
39  return false;
40  }
41  if(ilUserPasswordManager::getInstance()->verifyPassword($user, $this->getCredentials()->getPassword()))
42  {
43  $this->getLogger()->debug('Successfully authenticated user: ' . $this->getCredentials()->getUsername());
45  $status->setAuthenticatedUserId($user->getId());
46  return true;
47 
48  }
49  }
50  $this->handleAuthenticationFail($status, 'err_wrong_login');
51  return false;
52  }
53 }
54 ?>
setAuthenticatedUserId($a_id)
Description of class class.
static _loginExists($a_login, $a_user_id=0)
check if a login name already exists You may exclude a user from the check by giving his user id as 2...
Base class for authentication providers (radius, ldap, apache, ...)
Standard interface for auth provider implementations.
setStatus($a_status)
Set auth status.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
getLogger()
Get logger.
static isLocalPasswordEnabledForAuthMode($a_authmode)
Check if local password validation is enabled for a specific auth_mode.
handleAuthenticationFail(ilAuthStatus $status, $a_reason)
Handle failed authentication.
doAuthentication(\ilAuthStatus $status)
Do authentication.
Auth status implementation.
static getInstance()
Single method to reduce footprint (included files, created instances)