ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilCASAttributeToUser.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
11{
15 private $logger = null;
16
20 private $writer = null;
21
25 private $settings = null;
26
27
35 {
36 global $DIC;
37
38 $this->logger = $DIC->logger()->auth();
39
40 include_once('./Services/Xml/classes/class.ilXmlWriter.php');
41 $this->writer = new ilXmlWriter();
42
43 $this->settings = $settings;
44 }
45
53 public function create($a_username)
54 {
55 $this->writer->xmlStartTag('Users');
56
57 // Single users
58 // Required fields
59 // Create user
60 $this->writer->xmlStartTag('User', array('Action' => 'Insert'));
61 $this->writer->xmlElement('Login', array(), $new_name = ilAuthUtils::_generateLogin($a_username));
62
63 // Assign to role only for new users
64 $this->writer->xmlElement(
65 'Role', array(
66 'Id' => $this->settings->getDefaultRole(),
67 'Type' => 'Global',
68 'Action' => 'Assign'), '');
69
70 $this->writer->xmlElement('Active', array(), "true");
71 $this->writer->xmlElement('TimeLimitOwner', array(), 7);
72 $this->writer->xmlElement('TimeLimitUnlimited', array(), 1);
73 $this->writer->xmlElement('TimeLimitFrom', array(), time());
74 $this->writer->xmlElement('TimeLimitUntil', array(), time());
75 $this->writer->xmlElement('AuthMode', array('type' => 'cas'), 'cas');
76 $this->writer->xmlElement('ExternalAccount', array(), $a_username);
77
78 $this->writer->xmlEndTag('User');
79 $this->writer->xmlEndTag('Users');
80
81 $this->logger->info('CAS: Startet creation of user: ' . $new_name);
82
83 include_once './Services/User/classes/class.ilUserImportParser.php';
84 $importParser = new ilUserImportParser();
85 $importParser->setXMLContent($this->writer->xmlDumpMem(false));
86 $importParser->setRoleAssignment(
87 array(
88 $this->settings->getDefaultRole() => $this->settings->getDefaultRole()
89 )
90 );
91 $importParser->setFolderId(7);
92 $importParser->startParsing();
93
94 return $new_name;
95 }
96}
An exception for terminatinating execution or to throw for unit testing.
static _generateLogin($a_login)
generate free login by starting with a default string and adding postfix numbers
CAS user creation helper.
create($a_username)
Create new ILIAS account.
__construct(\ilCASSettings $settings)
Constructor.
Description of class.
XML writer class.
settings()
Definition: settings.php:2
global $DIC