ILIAS  release_8 Revision v8.24
class.ilCASAttributeToUser.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
5/******************************************************************************
6 *
7 * This file is part of ILIAS, a powerful learning management system.
8 *
9 * ILIAS is licensed with the GPL-3.0, you should have received a copy
10 * of said license along with the source code.
11 *
12 * If this is not the case or you just want to try ILIAS, you'll find
13 * us at:
14 * https://www.ilias.de
15 * https://github.com/ILIAS-eLearning
16 *
17 *****************************************************************************/
18
25{
29
31 {
32 global $DIC;
33
34 $this->logger = $DIC->logger()->auth();
35
36 $this->writer = new ilXmlWriter();
37
38 $this->settings = $settings;
39 }
40
41 public function create(string $a_username): string
42 {
43 $this->writer->xmlStartTag('Users');
44
45 $this->writer->xmlStartTag('User', array('Action' => 'Insert'));
46 $new_name = ilAuthUtils::_generateLogin($a_username);
47 $this->writer->xmlElement('Login', array(), $new_name);
48
49 // Assign to role only for new users
50 $this->writer->xmlElement(
51 'Role',
52 array(
53 'Id' => $this->settings->getDefaultRole(),
54 'Type' => 'Global',
55 'Action' => 'Assign'),
56 ''
57 );
58
59 $this->writer->xmlElement('Active', array(), "true");
60 $this->writer->xmlElement('TimeLimitOwner', array(), 7);
61 $this->writer->xmlElement('TimeLimitUnlimited', array(), 1);
62 $this->writer->xmlElement('TimeLimitFrom', array(), time());
63 $this->writer->xmlElement('TimeLimitUntil', array(), time());
64 $this->writer->xmlElement('AuthMode', array('type' => 'cas'), 'cas');
65 $this->writer->xmlElement('ExternalAccount', array(), $a_username);
66
67 $this->writer->xmlEndTag('User');
68 $this->writer->xmlEndTag('Users');
69
70 $this->logger->info('CAS: Startet creation of user: ' . $new_name);
71
72 $importParser = new ilUserImportParser();
73 $importParser->setXMLContent($this->writer->xmlDumpMem(false));
74 $importParser->setRoleAssignment(
75 array(
76 $this->settings->getDefaultRole() => $this->settings->getDefaultRole()
77 )
78 );
79 //TODO check if there is a constant
80 $importParser->setFolderId(7);
81 $importParser->startParsing();
82
83 return $new_name;
84 }
85}
static _generateLogin(string $a_login)
generate free login by starting with a default string and adding postfix numbers
CAS user creation helper.
__construct(\ilCASSettings $settings)
Component logger with individual log levels by component id.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28