24 include_once
'Auth/Container/MDB2.php';
55 self::$force_creation = $value;
58 function fetchData($a_username, $password, $isChallengeResponse=
false)
64 if (!$settings->get(
'apache_enable_auth'))
68 if (!$settings->get(
'apache_auth_indicator_name') || !$settings->get(
'apache_auth_indicator_value'))
77 if ($a_username ==
'anonymous' && $password ==
'anonymous') {
79 $query =
'SELECT * FROM usr_data WHERE login = %s';
80 $qres = $ilDB->queryF(
$query, array(
'text'), array($a_username));
82 $userRow = $ilDB->fetchAssoc($qres);
84 if (is_array($userRow) && $userRow[
'usr_id'])
88 $this->activeUser = $userRow[
'login'];
89 foreach ($userRow as $key => $value) {
90 if ($key == $this->options[
'passwordcol'] || $key == $this->options[
'usernamecol']) {
95 $this->_auth_obj->setAuthData($key, $value);
98 $this->_auth_obj->setAuth($userRow[
'login']);
104 if (!
$_SESSION[
'login_invalid'] && $_SERVER[$settings->get(
'apache_auth_indicator_name')] == $settings->get(
'apache_auth_indicator_value'))
109 if ($settings->get(
'apache_enable_local'))
111 $query =
'SELECT * FROM usr_data WHERE login = %s OR (auth_mode = %s AND ext_account = %s)';
112 $qres = $ilDB->queryF(
$query, array(
'text',
'text',
'text'), array($a_username,
'apache', $a_username));
114 $userRow = $ilDB->fetchAssoc($qres);
116 if (is_array($userRow) && $userRow[
'usr_id'])
120 $this->activeUser = $userRow[
'login'];
121 foreach ($userRow as $key => $value) {
122 if ($key == $this->options[
'passwordcol'] || $key == $this->options[
'usernamecol']) {
127 $this->_auth_obj->setAuthData($key, $value);
130 $this->_auth_obj->setAuth($userRow[
'login']);
136 if($settings->get(
'apache_enable_ldap'))
138 include_once
'Services/LDAP/classes/class.ilLDAPServer.php';
140 $this->server->doConnectionCheck();
142 $config = $this->server->toPearAuthArray();
145 $ldapUser =
$query->fetchUser($a_username);
147 if ($ldapUser && $ldapUser[$a_username] && $ldapUser[$a_username][
$config[
'userattr']] == $a_username)
150 $user_data = $ldapUser[$a_username];
151 if($this->server->enabledSyncOnLogin())
153 if(!$user_data[
'ilInternalAccount'] && $this->server->isAccountMigrationEnabled() && !
self::$force_creation)
155 $this->_auth_obj->logout();
157 $_SESSION[
'tmp_external_account'] = $a_username;
160 include_once(
'./Services/LDAP/classes/class.ilLDAPRoleAssignmentRules.php');
163 foreach($roles as $info)
171 ilUtil::redirect(
'ilias.php?baseClass=ilStartUpGUI&cmdClass=ilstartupgui&cmd=showAccountMigration');
178 $this->ldap_attr_to_user->setUserData($ldapUser);
179 $this->ldap_attr_to_user->refresh();
188 if ($user_data[
'ilInternalAccount'])
190 $this->_auth_obj->setAuth($user_data[
'ilInternalAccount']);
196 if ($settings->get(
'apache_enable_local') && $settings->get(
'apache_local_autocreate'))
213 $user->setLogin($a_username);
214 $user->setExternalAccount($a_username);
215 $user->setProfileIncomplete(
true);
217 $user->setAuthMode(
'apache');
221 $user->setLastPasswordChangeTS( time() );
222 $user->setTimeLimitUnlimited(1);
229 $rbacadmin->assignUser($settings->get(
'apache_default_role', 4),$user->getId(),
true);
253 include_once
'./Services/LDAP/classes/class.ilLDAPAttributeMapping.php';
256 #$GLOBALS['ilLog']->write(__METHOD__.': Required 2');
259 include_once
'./Services/LDAP/classes/class.ilLDAPRoleAssignmentRule.php';
262 #$GLOBALS['ilLog']->write(__METHOD__.': Required 3');
276 include_once(
'Services/LDAP/classes/class.ilLDAPAttributeToUser.php');