ILIAS  release_7 Revision v7.30-3-g800a261c036
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
5include_once './Services/Authentication/classes/Provider/class.ilAuthProvider.php';
6include_once './Services/Authentication/interfaces/interface.ilAuthProviderInterface.php';
7
15{
16
17
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 if ($user->getId() == ANONYMOUS_USER_ID) {
34 $this->getLogger()->notice('Failed authentication for anonymous user id. ');
35 $this->handleAuthenticationFail($status, 'err_wrong_login');
36 return false;
37 }
38 if (!ilAuthUtils::isLocalPasswordEnabledForAuthMode($user->getAuthMode(true))) {
39 $this->getLogger()->debug('DB authentication failed: current user auth mode does not allow local validation.');
40 $this->getLogger()->debug('User auth mode: ' . $user->getAuthMode(true));
41 $this->handleAuthenticationFail($status, 'err_wrong_login');
42 return false;
43 }
44 if (ilUserPasswordManager::getInstance()->verifyPassword($user, $this->getCredentials()->getPassword())) {
45 $this->getLogger()->debug('Successfully authenticated user: ' . $this->getCredentials()->getUsername());
47 $status->setAuthenticatedUserId($user->getId());
48 return true;
49 }
50 }
51 $this->handleAuthenticationFail($status, 'err_wrong_login');
52 return false;
53 }
54}
An exception for terminatinating execution or to throw for unit testing.
Description of class class.
Base class for authentication providers (radius, ldap, apache, ...)
getLogger()
Get logger.
handleAuthenticationFail(ilAuthStatus $status, $a_reason)
Handle failed authentication.
Auth status implementation.
static isLocalPasswordEnabledForAuthMode($a_authmode)
Check if local password validation is enabled for a specific auth_mode.
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...
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static getInstance()
Single method to reduce footprint (included files, created instances)
const ANONYMOUS_USER_ID
Definition: constants.php:25
Standard interface for auth provider implementations.
doAuthentication(\ilAuthStatus $status)
Do authentication.