ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilRadiusAttributeToUser.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
33{
40 public function __construct()
41 {
42 global $ilLog;
43
44 $this->log = $ilLog;
45
46 include_once('Services/Radius/classes/class.ilRadiusSettings.php');
47 $this->rad_settings = ilRadiusSettings::_getInstance();
48
49 include_once('./Services/Xml/classes/class.ilXmlWriter.php');
50 $this->writer = new ilXmlWriter();
51 }
52
60 public function create($a_username)
61 {
62 $this->writer->xmlStartTag('Users');
63
64 // Single users
65 // Required fields
66 // Create user
67 $this->writer->xmlStartTag('User',array('Action' => 'Insert'));
68 $this->writer->xmlElement('Login',array(),$new_name = ilAuthUtils::_generateLogin($a_username));
69
70 // Assign to role only for new users
71 $this->writer->xmlElement('Role',array('Id' => $this->rad_settings->getDefaultRole(),
72 'Type' => 'Global',
73 'Action' => 'Assign'),'');
74
75 $this->writer->xmlElement('Active',array(),"true");
76 $this->writer->xmlElement('TimeLimitOwner',array(),7);
77 $this->writer->xmlElement('TimeLimitUnlimited',array(),1);
78 $this->writer->xmlElement('TimeLimitFrom',array(),time());
79 $this->writer->xmlElement('TimeLimitUntil',array(),time());
80 $this->writer->xmlElement('AuthMode',array('type' => 'radius'),'radius');
81 $this->writer->xmlElement('ExternalAccount',array(),$a_username);
82
83 $this->writer->xmlEndTag('User');
84 $this->writer->xmlEndTag('Users');
85 $this->log->write('Radius: Started creation of user: '.$new_name);
86
87 include_once './Services/User/classes/class.ilUserImportParser.php';
88 $importParser = new ilUserImportParser();
89 $importParser->setXMLContent($this->writer->xmlDumpMem(false));
90 $importParser->setRoleAssignment(array($this->rad_settings->getDefaultRole() => $this->rad_settings->getDefaultRole()));
91 $importParser->setFolderId(7);
92 $importParser->startParsing();
93
94 return $new_name;
95 }
96}
97
98
99?>
_generateLogin($a_login)
generate free login by starting with a default string and adding postfix numbers
create($a_username)
Create new ILIAS account.
static _getInstance()
singleton get instance
XML writer class.