4require_once
'Auth/Container/MDB2.php';
24 parent::__construct();
32 self::$force_creation = $value;
42 public function fetchData($a_username,
$password, $isChallengeResponse =
false)
55 if (!$settings->get(
'apache_enable_auth')) {
59 if (!$settings->get(
'apache_auth_indicator_name') || !$settings->get(
'apache_auth_indicator_value')) {
68 if ($a_username ==
'anonymous' &&
$password ==
'anonymous') {
69 $query =
'SELECT * FROM usr_data WHERE login = %s';
70 $qres =
$ilDB->queryF(
$query, array(
'text'), array($a_username));
71 $userRow =
$ilDB->fetchAssoc($qres);
73 if (is_array($userRow) && $userRow[
'usr_id']) {
76 $this->activeUser = $userRow[
'login'];
77 foreach ($userRow as
$key => $value) {
78 if (
$key == $this->options[
'passwordcol'] ||
$key == $this->options[
'usernamecol']) {
83 $this->_auth_obj->setAuthData(
$key, $value);
86 $this->_auth_obj->setAuth($userRow[
'login']);
96 $_SERVER[$settings->get(
'apache_auth_indicator_name')],
97 array_filter(array_map(
'trim', str_getcsv($settings->get(
'apache_auth_indicator_value'))))
106 include_once(
'./Services/Authentication/classes/class.ilAuthModeDetermination.php');
108 if (!$det->isManualSelection() && $det->getCountActiveAuthModes() > 1) {
111 $list[] = $auth_mode;
116 include_once
'./Services/LDAP/classes/class.ilLDAPServer.php';
117 if ($settings->get(
'apache_enable_ldap')) {
122 foreach (
$list as $auth_mode) {
128 if ($settings->get(
'apache_enable_ldap')) {
129 include_once
'Services/LDAP/classes/class.ilLDAPServer.php';
130 $this->server =
new ilLDAPServer($settings->get(
'apache_ldap_sid'));
131 $this->server->doConnectionCheck();
133 $config = $this->server->toPearAuthArray();
137 $ldapUser =
$query->fetchUser($a_username);
139 if ($ldapUser && $ldapUser[$a_username] && $ldapUser[$a_username][
$config[
'userattr']] == $a_username) {
141 $user_data = $ldapUser[$a_username];
142 if ($this->server->enabledSyncOnLogin()) {
143 if (!$user_data[
'ilInternalAccount'] && $this->server->isAccountMigrationEnabled() && !self::$force_creation) {
144 $this->_auth_obj->logout();
146 $_SESSION[
'tmp_auth_mode_type'] =
'apache';
147 $_SESSION[
'tmp_external_account'] = $a_username;
150 include_once(
'./Services/LDAP/classes/class.ilLDAPRoleAssignmentRules.php');
152 $this->server->getServerId(),
157 foreach ($roles as
$info) {
163 ilUtil::redirect(
'ilias.php?baseClass=ilStartUpGUI&cmdClass=ilstartupgui&cmd=showAccountMigration');
168 $this->ldap_attr_to_user->setUserData($ldapUser);
169 $this->ldap_attr_to_user->refresh();
176 if ($user_data[
'ilInternalAccount']) {
177 $this->_auth_obj->setAuth($user_data[
'ilInternalAccount']);
178 $this->_auth_obj->username = $user_data[
'ilInternalAccount'];
183 } elseif (
AUTH_APACHE != $auth_mode && $settings->get(
'apache_enable_local')) {
186 $condition =
" AND auth_mode != " .
$ilDB->quote(
'default',
'text') .
" ";
188 $query =
"SELECT * FROM usr_data WHERE login = %s AND auth_mode != %s $condition";
189 $qres =
$ilDB->queryF(
$query, array(
'text',
'text'), array($a_username,
'ldap'));
190 $userRow =
$ilDB->fetchAssoc($qres);
192 if (is_array($userRow) && $userRow[
'usr_id']) {
195 $this->activeUser = $userRow[
'login'];
196 foreach ($userRow as
$key => $value) {
197 if (
$key == $this->options[
'passwordcol'] ||
$key == $this->options[
'usernamecol']) {
202 $this->_auth_obj->setAuthData(
$key, $value);
204 $this->_auth_obj->setAuth($userRow[
'login']);
210 if ($settings->get(
'apache_enable_local') && $settings->get(
'apache_local_autocreate')) {
216 $user->setLogin($a_username);
217 $user->setExternalAccount($a_username);
218 $user->setProfileIncomplete(
true);
220 $user->setAuthMode(
'apache');
223 $user->setLastPasswordChangeTS(time());
224 $user->setTimeLimitUnlimited(1);
230 $rbacadmin->assignUser($settings->get(
'apache_default_role', 4), $user->getId(),
true);
233 } elseif (
defined(
'IL_CERT_SSO') && IL_CERT_SSO) {
251 include_once
'./Services/LDAP/classes/class.ilLDAPAttributeMapping.php';
255 include_once
'./Services/LDAP/classes/class.ilLDAPRoleAssignmentRule.php';
268 include_once(
'Services/LDAP/classes/class.ilLDAPAttributeToUser.php');
280 include_once
'./Services/LDAP/classes/class.ilLDAPServer.php';
282 $settings->get(
'apache_ldap_sid')
287 include_once
'./Services/LDAP/classes/class.ilLDAPUserSynchronisation.php';
289 $sync->setExternalAccount($ext_account);
290 $sync->setUserData(array());
291 $sync->forceCreation(self::$force_creation);
292 $sync->forceReadLdapData(
true);
295 $internal_account =
$sync->sync();
296 }
catch (UnexpectedValueException $e) {
298 $a_auth->status = AUTH_WRONG_LOGIN;
310 ilUtil::redirect(
'ilias.php?baseClass=ilStartUpGUI&cmdClass=ilstartupgui&cmd=showAccountMigration');
313 $a_auth->setAuth($internal_account);
An exception for terminatinating execution or to throw for unit testing.
const AUTH_RADIUS_NO_ILIAS_USER
Authentication against ILIAS database.
initLDAPAttributeToUser()
Init LDAP attribute mapping @access private.
updateRequired($a_username)
Check if an update is required.
__construct()
Constructor.
static forceCreation($value)
handleLDAPDataSource($a_auth, $ext_account, $settings)
Handle ldap as data source.
static _getInstance()
Get instance.
Description of ilLDAPAccountMigrationRequiredException.
static hasRulesForUpdate($a_server_id)
Check if there is ldap attribute -> user data mapping which which is updated on login.
Update/create ILIAS user account by given LDAP attributes according to user attribute mapping setting...
static hasRulesForUpdate()
Check if there any rule for updates.
static getAssignmentsForCreation($a_server_id, $a_usr_name, $a_usr_data)
static getInstanceByServerId($a_server_id)
Get instance by server id.
Description of ilLDAPSyncronisationException.
Synchronization of user accounts used in auth container ldap, radius , cas,...
static getLogger($a_component_id)
Get component logger.
static _checkExternalAuthAccount($a_auth, $a_account, $tryFallback=true)
check whether external account and authentication method matches with a user
static redirect($a_script)
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
if(isset($_REQUEST['delete'])) $list
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']