ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilAuthContainerMultiple.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
24include_once 'Auth/Container.php';
25
26include_once './Services/Authentication/classes/class.ilAuthUtils.php';
27include_once './Services/Authentication/classes/class.ilAuthModeDetermination.php';
28
29
38{
39 protected $current_container = null;
40
45 public function __construct()
46 {
47 parent::__construct();
48
49 include_once './Services/Database/classes/class.ilAuthContainerMDB2.php';
50 $this->current_container = new ilAuthContainerMDB2();
51 }
52
56 public function failedLoginObserver($a_username, $a_auth)
57 {
58 $this->log('Auth_Container_Multiple: All containers rejected user credentials.', AUTH_LOG_DEBUG);
59 return false;
60 }
61
65 public function loginObserver($a_username, $a_auth)
66 {
67 $this->log('Container Multiple: loginObserver'.get_class($this->current_container),AUTH_LOG_DEBUG);
68 // Forward to current container
69 if($this->current_container instanceof Auth_Container)
70 {
71 $this->log('Container Multiple: Forwarding to '.get_class($this->current_container),AUTH_LOG_DEBUG);
72 return $this->current_container->loginObserver($a_username, $a_auth);
73 }
74 return false;
75 }
76
80 public function checkAuthObserver($a_username, $a_auth)
81 {
82 $this->log('Container Multiple: checkAuthObserver',AUTH_LOG_DEBUG);
83 // Forward to current container
84 if($this->current_container instanceof Auth_Container)
85 {
86 $this->log('Container Multiple: Forwarding to '.get_class($this->current_container),AUTH_LOG_DEBUG);
87 return $this->current_container->checkAuthObserver($a_username, $a_auth);
88 }
89 return false;
90 }
91
92
93 public function fetchData($user,$pass)
94 {
95 foreach(ilAuthModeDetermination::_getInstance()->getAuthModeSequence($user) as $auth_mode)
96 {
97 ilLoggerFactory::getLogger('auth')->debug('Current authmode is ' . $auth_mode . ' => ' . (int) $auth_mode);
98
99 if ($_REQUEST['force_mode_apache'])
100 {
101 $this->log('Container Apache: Trying new container',AUTH_LOG_DEBUG);
102 include_once './Services/AuthApache/classes/class.ilAuthContainerApache.php';
103 $this->current_container = new ilAuthContainerApache();
104
105 $auth = new ilAuthApache($this->current_container);
106 }
107 else
108 {
109 // begin-patch ldap_multiple
110 // cast to int
111 switch((int) $auth_mode)
112 {
113 case AUTH_LDAP:
114 $this->log('Container LDAP: Trying new container',AUTH_LOG_DEBUG);
115 include_once './Services/LDAP/classes/class.ilAuthContainerLDAP.php';
116 $sid = ilLDAPServer::getServerIdByAuthMode($auth_mode);
117 ilLoggerFactory::getLogger('auth')->debug('Trying LDAP server id ' . $sid);
118 $this->current_container = new ilAuthContainerLDAP($sid);
119 break;
120
121 case AUTH_LOCAL:
122 $this->log('Container MDB2: Trying new container',AUTH_LOG_DEBUG);
123 include_once './Services/Database/classes/class.ilAuthContainerMDB2.php';
124 $this->current_container = new ilAuthContainerMDB2();
125 break;
126
127 case AUTH_SOAP:
128 $this->log('Container SOAP: Trying new container',AUTH_LOG_DEBUG);
129 include_once './Services/SOAPAuth/classes/class.ilAuthContainerSOAP.php';
130 $this->current_container = new ilAuthContainerSOAP();
131 break;
132
133 case AUTH_RADIUS:
134 $this->log('Container Radius: Trying new container',AUTH_LOG_DEBUG);
135 include_once './Services/Radius/classes/class.ilAuthContainerRadius.php';
136 $this->current_container = new ilAuthContainerRadius();
137 break;
138
139 // begin-patch auth_plugin
140 default:
141 $this->log('Container Plugin: Trying new container',AUTH_LOG_DEBUG);
142 foreach(ilAuthUtils::getAuthPlugins() as $pl)
143 {
144 $container = $pl->getContainer($auth_mode);
145 if($container instanceof Auth_Container)
146 {
147 $this->current_container = $container;
148 break;
149 }
150 }
151 break;
152 // end-patch auth_plugin
153
154 }
155 }
156 $this->current_container->_auth_obj = $this->_auth_obj;
157
158 $result = $this->current_container->fetchData($user, $pass);
159
161 {
162 $this->log('Container '.$key.': '.$result->getMessage(), AUTH_LOG_ERR);
163 // Do not return here, otherwise wrong configured auth modes might block ilias database authentication
164 }
165 elseif ($result == true)
166 {
167 $this->log('Container '.$key.': Authentication successful.', AUTH_LOG_DEBUG);
168 return true;
169 }
170 else
171 {
172 $this->log('Container '.$key.': Authentication failed.', AUTH_LOG_DEBUG);
173 }
174 }
175 return false;
176 }
177
182 {
183 return true;
184 }
185}
186?>
const AUTH_LOG_DEBUG
Auth Log level - DEBUG.
Definition: Auth.php:59
$result
$_auth_obj
The Auth object this container is attached to.
Definition: Container.php:56
log($message, $level=AUTH_LOG_DEBUG)
Log a message to the Auth log.
Definition: Container.php:246
isError($data, $code=null)
Tell whether a value is a PEAR error.
Definition: PEAR.php:279
const AUTH_LDAP
const AUTH_LOCAL
const AUTH_RADIUS
const AUTH_SOAP
@classDescription Apache based authentication
Authentication against ILIAS database.
Overwritten Pear class AuthContainerLDAP This class is overwritten to support nested groups.
Authentication against ILIAS database.
failedLoginObserver($a_username, $a_auth)
@classDescription Overwritten Pear class AuthContainerRadius This class is overwritten to support to ...
@classDescription Authentication against external SOAP server
static getAuthPlugins()
Get active enabled auth plugins.
static getServerIdByAuthMode($a_auth_mode)
Get auth id by auth mode.
static getLogger($a_component_id)
Get component logger.
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7