Exemple #1
0
<?php

chdir(dirname(__FILE__));
chdir('..');
include_once "Services/Context/classes/class.ilContext.php";
ilContext::init(ilContext::CONTEXT_CRON);
include_once 'Services/Authentication/classes/class.ilAuthFactory.php';
ilAuthFactory::setContext(ilAuthFactory::CONTEXT_CRON);
$_COOKIE["ilClientId"] = $_SERVER['argv'][3];
$_POST['username'] = $_SERVER['argv'][1];
$_POST['password'] = $_SERVER['argv'][2];
if ($_SERVER['argc'] < 4) {
    die("Usage: cron.php username password client\n");
}
include_once './include/inc.header.php';
// Start checks here
include_once './cron/classes/class.ilCronCheck.php';
$cron_check = new ilCronCheck();
$cron_check->start();
 /**
  * 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
     ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
 }
Exemple #3
0
<?php

chdir('..');
define('IL_CERT_SSO', true);
define('IL_COOKIE_PATH', $_REQUEST['cookie_path']);
if ($_REQUEST['ilias_path']) {
    define('ILIAS_HTTP_PATH', $_REQUEST['ilias_path']);
}
include_once './Services/Authentication/classes/class.ilAuthUtils.php';
$_POST['auth_mode'] = AUTH_APACHE;
ilAuthFactory::setContext(ilAuthFactory::CONTEXT_APACHE);
require_once "include/inc.header.php";
$redirect = $_GET['r'];
$validDomains = array();
$path = ILIAS_DATA_DIR . '/' . CLIENT_ID . '/apache_auth_allowed_domains.txt';
if (file_exists($path) && is_readable($path)) {
    foreach (file($path) as $line) {
        if (trim($line)) {
            $validDomains[] = trim($line);
        }
    }
}
$P = parse_url($redirect);
$redirectDomain = $P["host"];
$validRedirect = false;
foreach ($validDomains as $validDomain) {
    if ($redirectDomain === $validDomain) {
        $validRedirect = true;
        break;
    }
    if (strlen($redirectDomain) > strlen($validDomain) + 1) {
 protected function initIlias()
 {
     include_once "Services/Context/classes/class.ilContext.php";
     ilContext::init(ilContext::CONTEXT_ICAL);
     include_once './Services/Authentication/classes/class.ilAuthFactory.php';
     ilAuthFactory::setContext(ilAuthFactory::CONTEXT_CALENDAR_TOKEN);
     $_POST['username'] = '******';
     $_POST['password'] = '******';
     require_once "Services/Init/classes/class.ilInitialisation.php";
     ilInitialisation::initILIAS();
     $GLOBALS['lng']->loadLanguageModule('dateplaner');
 }
 function __initAuthenticationObject($a_auth_mode = AUTH_LOCAL)
 {
     include_once './Services/Authentication/classes/class.ilAuthFactory.php';
     ilAuthFactory::setContext(ilAuthFactory::CONTEXT_SOAP);
 }
 function _getAuthModeOfUser($a_username, $a_password, $a_db_handler = '')
 {
     global $ilDB;
     if (isset($_GET['ecs_hash']) or isset($_GET['ecs_hash_url'])) {
         ilAuthFactory::setContext(ilAuthFactory::CONTEXT_ECS);
         return AUTH_ECS;
     }
     if (isset($_POST['auth_mode'])) {
         return (int) $_POST['auth_mode'];
     }
     if (isset($_POST['oid_username']) or $_GET['oid_check_status']) {
         $GLOBALS['ilLog']->write(__METHOD__ . ' set context to open id');
         ilAuthFactory::setContext(ilAuthFactory::CONTEXT_OPENID);
         return AUTH_OPENID;
     }
     include_once './Services/Authentication/classes/class.ilAuthModeDetermination.php';
     $det = ilAuthModeDetermination::_getInstance();
     if (!$det->isManualSelection() and $det->getCountActiveAuthModes() > 1) {
         return AUTH_MULTIPLE;
     }
     $db =& $ilDB;
     if ($a_db_handler != '') {
         $db =& $a_db_handler;
     }
     // Is it really necessary to check the auth mode with password ?
     // Changed: smeyer
     $q = "SELECT auth_mode FROM usr_data WHERE " . "login = "******"passwd = ".$ilDB->quote(md5($a_password))."";
     $r = $db->query($q);
     $row = $r->fetchRow(DB_FETCHMODE_OBJECT);
     //echo "+".$row->auth_mode."+";
     $auth_mode = self::_getAuthMode($row->auth_mode, $db);
     return in_array($auth_mode, self::_getActiveAuthModes()) ? $auth_mode : AUTH_INACTIVE;
 }
Exemple #7
0
<?php

/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
chdir('../../..');
include_once 'Services/Authentication/classes/class.ilAuthFactory.php';
ilAuthFactory::setContext(ilAuthFactory::CONTEXT_SOAP);
include_once 'Services/Init/classes/class.ilInitialisation.php';
$ilInit = new ilInitialisation();
$GLOBALS['ilInit'] = $ilInit;
$ilInit->initILIAS('webdav');
include_once './Services/WebServices/Rest/classes/class.ilRestServer.php';
$server = new ilRestServer();
$server->config('debug', true);
$server->init();
$server->run();
Exemple #8
0
*/
// Initialize
// -----------------------------------------------------
// Retrieve the client id from PATH_INFO
// Component 1 contains the ILIAS client_id.
$path_info_components = explode('/', $_SERVER['PATH_INFO']);
$client_id = $path_info_components[1];
// For all requests, except for GET-Requests for files, we enforce HTTP
// authentication for the WebDAV protocol.
#if ($_SERVER['REQUEST_METHOD'] != 'GET' ||
#	count($path_info_components) < 3 ||
#	substr($path_info_components[2],0,5) != 'file_') {
#	define ('WebDAV_Authentication', 'HTTP');
#}
define('WebDAV_Authentication', 'HTTP');
// Set context for authentication
include_once 'Services/Authentication/classes/class.ilAuthFactory.php';
ilAuthFactory::setContext(ilAuthFactory::CONTEXT_HTTP);
// Launch ILIAS using the client id we have determined
// -----------------------------------------------------
$_COOKIE["ilClientId"] = $client_id;
include_once "Services/Context/classes/class.ilContext.php";
ilContext::init(ilContext::CONTEXT_WEBDAV);
require_once "Services/Init/classes/class.ilInitialisation.php";
ilInitialisation::initILIAS();
// Launch the WebDAV Server
// -----------------------------------------------------
include_once "Services/WebDAV/classes/class.ilDAVServer.php";
$server = new ilDAVServer();
$server->ServeRequest();
// END WebDAV