• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Services/Radius/classes/class.ilRadiusAttributeToUser.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2006 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00032 class ilRadiusAttributeToUser
00033 {
00040         public function __construct()
00041         {
00042                 global $ilLog;
00043                 
00044                 $this->log = $ilLog;
00045                 
00046                 include_once('Services/Radius/classes/class.ilRadiusSettings.php');
00047                 $this->rad_settings = ilRadiusSettings::_getInstance();
00048 
00049                 include_once('classes/class.ilXmlWriter.php');
00050                 $this->writer = new ilXmlWriter();
00051         }
00052         
00060         public function create($a_username)
00061         {
00062                 $this->writer->xmlStartTag('Users');
00063                 
00064                 // Single users
00065                 // Required fields
00066                 // Create user
00067                 $this->writer->xmlStartTag('User',array('Action' => 'Insert'));
00068                 $this->writer->xmlElement('Login',array(),$new_name = ilAuthUtils::_generateLogin($a_username));
00069                                 
00070                 // Assign to role only for new users
00071                 $this->writer->xmlElement('Role',array('Id' => $this->rad_settings->getDefaultRole(),
00072                         'Type' => 'Global',
00073                         'Action' => 'Assign'),'');
00074 
00075                 $this->writer->xmlElement('Active',array(),"true");
00076                 $this->writer->xmlElement('TimeLimitOwner',array(),7);
00077                 $this->writer->xmlElement('TimeLimitUnlimited',array(),1);
00078                 $this->writer->xmlElement('TimeLimitFrom',array(),time());
00079                 $this->writer->xmlElement('TimeLimitUntil',array(),time());
00080                 $this->writer->xmlElement('AuthMode',array('type' => 'radius'),'radius');
00081                 $this->writer->xmlElement('ExternalAccount',array(),$a_username);
00082                         
00083                 $this->writer->xmlEndTag('User');
00084                 $this->writer->xmlEndTag('Users');
00085                 $this->log->write('Radius: Started creation of user: '.$new_name);
00086                 
00087                 include_once './Services/User/classes/class.ilUserImportParser.php';
00088                 $importParser = new ilUserImportParser();
00089                 $importParser->setXMLContent($this->writer->xmlDumpMem(false));
00090                 $importParser->setRoleAssignment(array($this->rad_settings->getDefaultRole() => $this->rad_settings->getDefaultRole()));
00091                 $importParser->setFolderId(7);
00092                 $importParser->startParsing();
00093                 
00094                 return $new_name;
00095         }
00096 }
00097 
00098 
00099 ?>

Generated on Fri Dec 13 2013 17:57:00 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1