ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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',
66  array(
67  'Id' => $this->settings->getDefaultRole(),
68  'Type' => 'Global',
69  'Action' => 'Assign'),
70  ''
71  );
72 
73  $this->writer->xmlElement('Active', array(), "true");
74  $this->writer->xmlElement('TimeLimitOwner', array(), 7);
75  $this->writer->xmlElement('TimeLimitUnlimited', array(), 1);
76  $this->writer->xmlElement('TimeLimitFrom', array(), time());
77  $this->writer->xmlElement('TimeLimitUntil', array(), time());
78  $this->writer->xmlElement('AuthMode', array('type' => 'cas'), 'cas');
79  $this->writer->xmlElement('ExternalAccount', array(), $a_username);
80 
81  $this->writer->xmlEndTag('User');
82  $this->writer->xmlEndTag('Users');
83 
84  $this->logger->info('CAS: Startet creation of user: ' . $new_name);
85 
86  include_once './Services/User/classes/class.ilUserImportParser.php';
87  $importParser = new ilUserImportParser();
88  $importParser->setXMLContent($this->writer->xmlDumpMem(false));
89  $importParser->setRoleAssignment(
90  array(
91  $this->settings->getDefaultRole() => $this->settings->getDefaultRole()
92  )
93  );
94  $importParser->setFolderId(7);
95  $importParser->startParsing();
96 
97  return $new_name;
98  }
99 }
settings()
Definition: settings.php:2
global $DIC
Definition: saml.php:7
static _generateLogin($a_login)
generate free login by starting with a default string and adding postfix numbers
XML writer class.
CAS user creation helper.
__construct(\ilCASSettings $settings)
Constructor.
Description of class.
create($a_username)
Create new ILIAS account.