当前位置: 首页>>代码示例>>PHP>>正文


PHP ilObjUser::setAuthMode方法代码示例

本文整理汇总了PHP中ilObjUser::setAuthMode方法的典型用法代码示例。如果您正苦于以下问题:PHP ilObjUser::setAuthMode方法的具体用法?PHP ilObjUser::setAuthMode怎么用?PHP ilObjUser::setAuthMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ilObjUser的用法示例。


在下文中一共展示了ilObjUser::setAuthMode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: fetchData


//.........这里部分代码省略.........
                 $this->activeUser = $userRow['login'];
                 foreach ($userRow as $key => $value) {
                     if ($key == $this->options['passwordcol'] || $key == $this->options['usernamecol']) {
                         continue;
                     }
                     // Use reference to the auth object if exists
                     // This is because the auth session variable can change so a static call to setAuthData does not make sense
                     $this->_auth_obj->setAuthData($key, $value);
                 }
                 //var_dump($userRow);
                 $this->_auth_obj->setAuth($userRow['login']);
                 return true;
             }
         }
         // if no local user has been found AND ldap lookup is enabled
         if ($settings->get('apache_enable_ldap')) {
             include_once 'Services/LDAP/classes/class.ilLDAPServer.php';
             $this->server = new ilLDAPServer(ilLDAPServer::_getFirstActiveServer());
             $this->server->doConnectionCheck();
             $config = $this->server->toPearAuthArray();
             $query = new ilLDAPQuery($this->server);
             $ldapUser = $query->fetchUser($a_username);
             if ($ldapUser && $ldapUser[$a_username] && $ldapUser[$a_username][$config['userattr']] == $a_username) {
                 $ldapUser[$a_username]['ilInternalAccount'] = ilObjUser::_checkExternalAuthAccount("apache", $a_username);
                 $user_data = $ldapUser[$a_username];
                 //array_change_key_case($a_auth->getAuthData(),CASE_LOWER);
                 if ($this->server->enabledSyncOnLogin()) {
                     if (!$user_data['ilInternalAccount'] && $this->server->isAccountMigrationEnabled() && !self::$force_creation) {
                         $this->_auth_obj->logout();
                         $_SESSION['tmp_auth_mode'] = 'apache';
                         $_SESSION['tmp_external_account'] = $a_username;
                         $_SESSION['tmp_pass'] = $_POST['password'];
                         include_once './Services/LDAP/classes/class.ilLDAPRoleAssignmentRules.php';
                         $roles = ilLDAPRoleAssignmentRules::getAssignmentsForCreation($a_username, $user_data);
                         $_SESSION['tmp_roles'] = array();
                         foreach ($roles as $info) {
                             if ($info['action'] == ilLDAPRoleAssignmentRules::ROLE_ACTION_ASSIGN) {
                                 $_SESSION['tmp_roles'][] = $info['id'];
                             }
                         }
                         ilUtil::redirect('ilias.php?baseClass=ilStartUpGUI&cmdClass=ilstartupgui&cmd=showAccountMigration');
                         exit;
                     }
                     if ($this->updateRequired($a_username)) {
                         $this->initLDAPAttributeToUser();
                         $this->ldap_attr_to_user->setUserData($ldapUser);
                         $this->ldap_attr_to_user->refresh();
                         $user_data['ilInternalAccount'] = ilObjUser::_checkExternalAuthAccount("apache", $a_username);
                     } else {
                         // User exists and no update required
                         $user_data['ilInternalAccount'] = ilObjUser::_checkExternalAuthAccount("apache", $a_username);
                     }
                 }
                 if ($user_data['ilInternalAccount']) {
                     $this->_auth_obj->setAuth($user_data['ilInternalAccount']);
                     return true;
                 }
             }
         }
         if ($settings->get('apache_enable_local') && $settings->get('apache_local_autocreate')) {
             // no local user, no ldap match or ldap not activated
             //				if (!self::$force_creation)
             //				{
             //					$_SESSION['tmp_auth_mode'] = 'apache';
             //					$_SESSION['tmp_external_account'] = $a_username;
             //					$_SESSION['tmp_pass'] = $_POST['password'];
             //ilUtil::redirect('https://lernwelt.janposselt.de/ilias.php?baseClass=ilStartUpGUI&cmdClass=ilstartupgui&cmd=showAccountMigration');
             //				}
             //				else
             //				{
             global $ilIliasIniFile;
             if ($_GET['r']) {
                 $_SESSION['profile_complete_redirect'] = $_GET['r'];
             }
             $user = new ilObjUser();
             $user->setLogin($a_username);
             $user->setExternalAccount($a_username);
             $user->setProfileIncomplete(true);
             $user->create();
             $user->setAuthMode('apache');
             // set a timestamp for last_password_change
             // this ts is needed by ilSecuritySettings
             $user->setLastPasswordChangeTS(time());
             $user->setTimeLimitUnlimited(1);
             $user->setActive(1);
             //insert user data in table user_data
             $user->saveAsNew();
             $user->writePrefs();
             global $rbacadmin;
             $rbacadmin->assignUser($settings->get('apache_default_role', 4), $user->getId(), true);
             return true;
             //				}
         }
     } else {
         if (defined('IL_CERT_SSO') && IL_CERT_SSO) {
             define('APACHE_ERRORCODE', AUTH_APACHE_FAILED);
         }
     }
     return false;
 }
开发者ID:Walid-Synakene,项目名称:ilias,代码行数:101,代码来源:class.ilAuthContainerApache.php

示例2: importEndTag


//.........这里部分代码省略.........
                         if (!is_null($this->currActive)) {
                             $updateUser->setActive($this->currActive == "true", is_object($ilUser) ? $ilUser->getId() : 0);
                         }
                         if (!is_null($this->userObj->getClientIP())) {
                             $updateUser->setClientIP($this->userObj->getClientIP());
                         }
                         if (!is_null($this->userObj->getTimeLimitUnlimited())) {
                             $updateUser->setTimeLimitUnlimited($this->userObj->getTimeLimitUnlimited());
                         }
                         if (!is_null($this->userObj->getTimeLimitFrom())) {
                             $updateUser->setTimeLimitFrom($this->userObj->getTimeLimitFrom());
                         }
                         if (!is_null($this->userObj->getTimeLimitUntil())) {
                             $updateUser->setTimeLimitUntil($this->userObj->getTimeLimitUntil());
                         }
                         if (!is_null($this->userObj->getTimeLimitMessage())) {
                             $updateUser->setTimeLimitMessage($this->userObj->getTimeLimitMessage());
                         }
                         if (!is_null($this->userObj->getApproveDate())) {
                             $updateUser->setApproveDate($this->userObj->getApproveDate());
                         }
                         if (!is_null($this->userObj->getAgreeDate())) {
                             $updateUser->setAgreeDate($this->userObj->getAgreeDate());
                         }
                         if (!is_null($this->userObj->getLanguage())) {
                             $updateUser->setLanguage($this->userObj->getLanguage());
                         }
                         if (!is_null($this->userObj->getExternalAccount())) {
                             $updateUser->setExternalAccount($this->userObj->getExternalAccount());
                         }
                         // Fixed: if auth_mode is not set, it was always overwritten with auth_default
                         #if (! is_null($this->userObj->getAuthMode())) $updateUser->setAuthMode($this->userObj->getAuthMode());
                         if ($this->auth_mode_set) {
                             $updateUser->setAuthMode($this->userObj->getAuthMode());
                         }
                         if (!is_null($this->userObj->getInstantMessengerId("aim"))) {
                             $updateUser->setInstantMessengerId("aim", $this->userObj->getInstantMessengerId("aim"));
                         }
                         if (!is_null($this->userObj->getInstantMessengerId("msn"))) {
                             $updateUser->setInstantMessengerId("msn", $this->userObj->getInstantMessengerId("msn"));
                         }
                         if (!is_null($this->userObj->getInstantMessengerId("icq"))) {
                             $updateUser->setInstantMessengerId("icq", $this->userObj->getInstantMessengerId("icq"));
                         }
                         if (!is_null($this->userObj->getInstantMessengerId("yahoo"))) {
                             $updateUser->setInstantMessengerId("yahoo", $this->userObj->getInstantMessengerId("yahoo"));
                         }
                         if (!is_null($this->userObj->getInstantMessengerId("skype"))) {
                             $updateUser->setInstantMessengerId("skype", $this->userObj->getInstantMessengerId("skype"));
                         }
                         if (!is_null($this->userObj->getInstantMessengerId("jabber"))) {
                             $updateUser->setInstantMessengerId("jabber", $this->userObj->getInstantMessengerId("jabber"));
                         }
                         if (!is_null($this->userObj->getInstantMessengerId("voip"))) {
                             $updateUser->setInstantMessengerId("voip", $this->userObj->getInstantMessengerId("voip"));
                         }
                         // Special handlin since it defaults to 7 (USER_FOLDER_ID)
                         if ($this->time_limit_owner_set) {
                             $updateUser->setTimeLimitOwner($this->userObj->getTimeLimitOwner());
                         }
                         if (count($this->prefs)) {
                             foreach ($this->prefs as $key => $value) {
                                 if ($key != "mail_incoming_type" && $key != "mail_signature" && $key != "mail_linebreak") {
                                     $updateUser->setPref($key, $value);
                                 }
                             }
开发者ID:khanhnnvn,项目名称:ilias_E-learning,代码行数:67,代码来源:class.ilUserImportParser.php

示例3: fetchData


//.........这里部分代码省略.........
                 if ($settings->get('apache_enable_ldap')) {
                     include_once 'Services/LDAP/classes/class.ilLDAPServer.php';
                     $this->server = new ilLDAPServer(ilLDAPServer::_getFirstActiveServer());
                     $this->server->doConnectionCheck();
                     $config = $this->server->toPearAuthArray();
                     $query = new ilLDAPQuery($this->server);
                     $query->bind();
                     $ldapUser = $query->fetchUser($a_username);
                     if ($ldapUser && $ldapUser[$a_username] && $ldapUser[$a_username][$config['userattr']] == $a_username) {
                         $ldapUser[$a_username]['ilInternalAccount'] = ilObjUser::_checkExternalAuthAccount("ldap", $a_username);
                         $user_data = $ldapUser[$a_username];
                         //array_change_key_case($a_auth->getAuthData(),CASE_LOWER);
                         if ($this->server->enabledSyncOnLogin()) {
                             if (!$user_data['ilInternalAccount'] && $this->server->isAccountMigrationEnabled() && !self::$force_creation) {
                                 $this->_auth_obj->logout();
                                 $_SESSION['tmp_auth_mode'] = 'ldap';
                                 $_SESSION['tmp_external_account'] = $a_username;
                                 $_SESSION['tmp_pass'] = $_POST['password'];
                                 include_once './Services/LDAP/classes/class.ilLDAPRoleAssignmentRules.php';
                                 $roles = ilLDAPRoleAssignmentRules::getAssignmentsForCreation($a_username, $user_data);
                                 $_SESSION['tmp_roles'] = array();
                                 foreach ($roles as $info) {
                                     if ($info['action'] == ilLDAPRoleAssignmentRules::ROLE_ACTION_ASSIGN) {
                                         $_SESSION['tmp_roles'][] = $info['id'];
                                     }
                                 }
                                 ilUtil::redirect('ilias.php?baseClass=ilStartUpGUI&cmdClass=ilstartupgui&cmd=showAccountMigration');
                             }
                             if ($this->updateRequired($a_username)) {
                                 $this->initLDAPAttributeToUser();
                                 $this->ldap_attr_to_user->setUserData($ldapUser);
                                 $this->ldap_attr_to_user->refresh();
                                 $user_data['ilInternalAccount'] = ilObjUser::_checkExternalAuthAccount("ldap", $a_username);
                             } else {
                                 // User exists and no update required
                                 $user_data['ilInternalAccount'] = ilObjUser::_checkExternalAuthAccount("ldap", $a_username);
                             }
                         }
                         if ($user_data['ilInternalAccount']) {
                             $this->_auth_obj->setAuth($user_data['ilInternalAccount']);
                             $this->_auth_obj->username = $user_data['ilInternalAccount'];
                             return true;
                         }
                     }
                 }
             } else {
                 if (AUTH_APACHE != $auth_mode && $settings->get('apache_enable_local')) {
                     $condition = '';
                     if ($ilSetting->get("auth_mode") && $ilSetting->get("auth_mode") == 'ldap') {
                         $condition = " AND auth_mode != " . $ilDB->quote('default', 'text') . " ";
                     }
                     $query = "SELECT * FROM usr_data WHERE login = %s AND auth_mode != %s {$condition}";
                     $qres = $ilDB->queryF($query, array('text', 'text'), array($a_username, 'ldap'));
                     $userRow = $ilDB->fetchAssoc($qres);
                     if (is_array($userRow) && $userRow['usr_id']) {
                         // user as a local account...
                         // fetch logindata
                         $this->activeUser = $userRow['login'];
                         foreach ($userRow as $key => $value) {
                             if ($key == $this->options['passwordcol'] || $key == $this->options['usernamecol']) {
                                 continue;
                             }
                             // Use reference to the auth object if exists
                             // This is because the auth session variable can change so a static call to setAuthData does not make sense
                             $this->_auth_obj->setAuthData($key, $value);
                         }
                         $this->_auth_obj->setAuth($userRow['login']);
                         return true;
                     }
                 }
             }
         }
         if ($settings->get('apache_enable_local') && $settings->get('apache_local_autocreate')) {
             if ($_GET['r']) {
                 $_SESSION['profile_complete_redirect'] = $_GET['r'];
             }
             $user = new ilObjUser();
             $user->setLogin($a_username);
             $user->setExternalAccount($a_username);
             $user->setProfileIncomplete(true);
             $user->create();
             $user->setAuthMode('apache');
             // set a timestamp for last_password_change
             // this ts is needed by ilSecuritySettings
             $user->setLastPasswordChangeTS(time());
             $user->setTimeLimitUnlimited(1);
             $user->setActive(1);
             //insert user data in table user_data
             $user->saveAsNew();
             $user->writePrefs();
             $rbacadmin->assignUser($settings->get('apache_default_role', 4), $user->getId(), true);
             return true;
         }
     } else {
         if (defined('IL_CERT_SSO') && IL_CERT_SSO) {
             define('APACHE_ERRORCODE', AUTH_APACHE_FAILED);
         }
     }
     return false;
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:101,代码来源:class.ilAuthContainerApache.php

示例4: migrateAccount

 /**
  * migrate account
  *
  * @access public
  * 
  */
 public function migrateAccount()
 {
     global $lng, $ilClientIniFile, $ilLog, $rbacadmin;
     $lng->loadLanguageModule('auth');
     if (!isset($_POST['account_migration'])) {
         $this->showAccountMigration($lng->txt('err_choose_migration_type'));
         return false;
     }
     if ($_POST['account_migration'] == 1 and (!strlen($_POST['mig_username']) or !strlen($_POST['mig_password']))) {
         $this->showAccountMigration($lng->txt('err_wrong_login'));
         return false;
     }
     if ($_POST['account_migration'] == 1) {
         if (!($user_id = ilObjUser::_lookupId(ilUtil::stripSlashes($_POST['mig_username'])))) {
             $this->showAccountMigration($lng->txt('err_wrong_login'));
             return false;
         }
         $_POST['username'] = $_POST['mig_username'];
         $_POST['password'] = $_POST['mig_password'];
         include_once './Services/Authentication/classes/class.ilAuthFactory.php';
         include_once './Services/Database/classes/class.ilAuthContainerMDB2.php';
         $ilAuth = ilAuthFactory::factory(new ilAuthContainerMDB2());
         $ilAuth->start();
         if (!$ilAuth->checkAuth()) {
             $ilAuth->logout();
             $this->showAccountMigration($lng->txt('err_wrong_login'));
             return false;
         }
         $user = new ilObjUser($user_id);
         $user->setAuthMode(ilSession::get('tmp_auth_mode'));
         $user->setExternalAccount(ilSession::get('tmp_external_account'));
         $user->setActive(true);
         $user->update();
         // Assign to default role
         if (is_array(ilSession::get('tmp_roles'))) {
             foreach (ilSession::get('tmp_roles') as $role) {
                 $rbacadmin->assignUser((int) $role, $user->getId());
             }
         }
         // Log migration
         $ilLog->write(__METHOD__ . ': Migrated ' . ilSession::get('tmp_external_account') . ' to ILIAS account ' . $user->getLogin() . '.');
     } elseif ($_POST['account_migration'] == 2) {
         switch (ilSession::get('tmp_auth_mode')) {
             case 'apache':
                 $_POST['username'] = ilSession::get('tmp_external_account');
                 $_POST['password'] = ilSession::get('tmp_pass');
                 include_once 'Services/AuthApache/classes/class.ilAuthContainerApache.php';
                 $container = new ilAuthContainerApache();
                 $container->forceCreation(true);
                 $ilAuth = ilAuthFactory::factory($container);
                 $ilAuth->start();
                 break;
             case 'ldap':
                 $_POST['username'] = ilSession::get('tmp_external_account');
                 $_POST['password'] = ilSession::get('tmp_pass');
                 include_once 'Services/LDAP/classes/class.ilAuthContainerLDAP.php';
                 $container = new ilAuthContainerLDAP();
                 $container->forceCreation(true);
                 $ilAuth = ilAuthFactory::factory($container);
                 $ilAuth->start();
                 break;
             case 'radius':
                 $_POST['username'] = ilSession::get('tmp_external_account');
                 $_POST['password'] = ilSession::get('tmp_pass');
                 include_once './Services/Authentication/classes/class.ilAuthFactory.php';
                 include_once './Services/Radius/classes/class.ilAuthContainerRadius.php';
                 $container = new ilAuthContainerRadius();
                 $container->forceCreation(true);
                 $ilAuth = ilAuthFactory::factory($container);
                 $ilAuth->start();
                 break;
             case 'openid':
                 $_POST['username'] = ilSession::get('dummy');
                 $_POST['password'] = ilSession::get('dummy');
                 $_POST['oid_username'] = ilSession::get('tmp_oid_username');
                 $_POST['oid_provider'] = ilSession::get('tmp_oid_provider');
                 //ilSession::set('force_creation', true);
                 include_once './Services/Authentication/classes/class.ilAuthFactory.php';
                 include_once './Services/OpenId/classes/class.ilAuthContainerOpenId.php';
                 $container = new ilAuthContainerOpenId();
                 $container->forceCreation(true);
                 ilAuthFactory::setContext(ilAuthFactory::CONTEXT_OPENID);
                 include_once './Services/OpenId/classes/class.ilAuthOpenId.php';
                 $ilAuth = ilAuthFactory::factory($container);
                 // logout first to initiate a new login session
                 $ilAuth->logout();
                 ilSession::_destroy(session_id());
                 ilSession::set('force_creation', true);
                 $ilAuth->start();
         }
         // Redirect to acceptance
         ilUtil::redirect("ilias.php?baseClass=ilStartUpGUI&cmdClass=ilstartupgui&target=" . $_GET["target"] . "&cmd=getAcceptance");
     }
     // show personal desktop
//.........这里部分代码省略.........
开发者ID:arlendotcn,项目名称:ilias,代码行数:101,代码来源:class.ilStartUpGUI.php


注:本文中的ilObjUser::setAuthMode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。