4 require_once
'Auth/Container/MDB2.php';
32 self::$force_creation = $value;
42 function fetchData($a_username, $password, $isChallengeResponse =
false)
53 if(!$settings->get(
'apache_enable_auth'))
57 if(!$settings->get(
'apache_auth_indicator_name') || !$settings->get(
'apache_auth_indicator_value'))
66 if($a_username ==
'anonymous' && $password ==
'anonymous')
68 $query =
'SELECT * FROM usr_data WHERE login = %s';
69 $qres = $ilDB->queryF(
$query, array(
'text'), array($a_username));
70 $userRow = $ilDB->fetchAssoc($qres);
72 if(is_array($userRow) && $userRow[
'usr_id'])
76 $this->activeUser = $userRow[
'login'];
77 foreach($userRow as $key => $value)
79 if($key == $this->options[
'passwordcol'] || $key == $this->options[
'usernamecol'])
85 $this->_auth_obj->setAuthData($key, $value);
87 $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'))))
103 $ilSetting->get(
'auth_mode')
107 include_once(
'./Services/Authentication/classes/class.ilAuthModeDetermination.php');
109 if(!$det->isManualSelection() && $det->getCountActiveAuthModes() > 1)
114 $list[] = $auth_mode;
118 foreach($list as $auth_mode)
123 if($settings->get(
'apache_enable_ldap'))
125 include_once
'Services/LDAP/classes/class.ilLDAPServer.php';
127 $this->server->doConnectionCheck();
129 $config = $this->server->toPearAuthArray();
133 $ldapUser =
$query->fetchUser($a_username);
135 if($ldapUser && $ldapUser[$a_username] && $ldapUser[$a_username][$config[
'userattr']] == $a_username)
138 $user_data = $ldapUser[$a_username];
139 if($this->server->enabledSyncOnLogin())
141 if(!$user_data[
'ilInternalAccount'] && $this->server->isAccountMigrationEnabled() && !
self::$force_creation)
143 $this->_auth_obj->logout();
145 $_SESSION[
'tmp_external_account'] = $a_username;
148 include_once(
'./Services/LDAP/classes/class.ilLDAPRoleAssignmentRules.php');
151 foreach($roles as $info)
159 ilUtil::redirect(
'ilias.php?baseClass=ilStartUpGUI&cmdClass=ilstartupgui&cmd=showAccountMigration');
165 $this->ldap_attr_to_user->setUserData($ldapUser);
166 $this->ldap_attr_to_user->refresh();
175 if($user_data[
'ilInternalAccount'])
177 $this->_auth_obj->setAuth($user_data[
'ilInternalAccount']);
178 $this->_auth_obj->username = $user_data[
'ilInternalAccount'];
184 else if(
AUTH_APACHE != $auth_mode && $settings->get(
'apache_enable_local'))
187 if($ilSetting->get(
"auth_mode") && $ilSetting->get(
"auth_mode") ==
'ldap')
189 $condition =
" AND auth_mode != " . $ilDB->quote(
'default',
'text') .
" ";
191 $query =
"SELECT * FROM usr_data WHERE login = %s AND auth_mode != %s $condition";
192 $qres = $ilDB->queryF(
$query, array(
'text',
'text'), array($a_username,
'ldap'));
193 $userRow = $ilDB->fetchAssoc($qres);
195 if(is_array($userRow) && $userRow[
'usr_id'])
199 $this->activeUser = $userRow[
'login'];
200 foreach($userRow as $key => $value)
202 if($key == $this->options[
'passwordcol'] || $key == $this->options[
'usernamecol'])
208 $this->_auth_obj->setAuthData($key, $value);
210 $this->_auth_obj->setAuth($userRow[
'login']);
216 if($settings->get(
'apache_enable_local') && $settings->get(
'apache_local_autocreate'))
224 $user->setLogin($a_username);
225 $user->setExternalAccount($a_username);
226 $user->setProfileIncomplete(
true);
228 $user->setAuthMode(
'apache');
231 $user->setLastPasswordChangeTS(time());
232 $user->setTimeLimitUnlimited(1);
238 $rbacadmin->assignUser($settings->get(
'apache_default_role', 4), $user->getId(),
true);
262 include_once
'./Services/LDAP/classes/class.ilLDAPAttributeMapping.php';
267 include_once
'./Services/LDAP/classes/class.ilLDAPRoleAssignmentRule.php';
281 include_once(
'Services/LDAP/classes/class.ilLDAPAttributeToUser.php');