ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilCASAttributeToUser Class Reference

CAS user creation helper. More...

+ Collaboration diagram for ilCASAttributeToUser:

Public Member Functions

 __construct (\ilCASSettings $settings)
 
 create (string $a_username)
 

Private Attributes

ilLogger $logger
 
ilXmlWriter $writer
 
ilCASSettings $settings
 

Detailed Description

CAS user creation helper.

Author
Stefan Meyer smeye.nosp@m.r.il.nosp@m.ias@g.nosp@m.mx.d.nosp@m.e

Definition at line 26 of file class.ilCASAttributeToUser.php.

Constructor & Destructor Documentation

◆ __construct()

ilCASAttributeToUser::__construct ( \ilCASSettings  $settings)

Definition at line 32 of file class.ilCASAttributeToUser.php.

References $DIC, $settings, ILIAS\Repository\logger(), and ILIAS\Repository\settings().

33  {
34  global $DIC;
35 
36  $this->logger = $DIC->logger()->auth();
37 
38  $this->writer = new ilXmlWriter();
39 
40  $this->settings = $settings;
41  }
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ create()

ilCASAttributeToUser::create ( string  $a_username)

Definition at line 43 of file class.ilCASAttributeToUser.php.

References ilAuthUtils\_generateLogin(), ILIAS\Repository\logger(), and ILIAS\Repository\settings().

43  : string
44  {
45  $this->writer->xmlStartTag('Users');
46 
47  $this->writer->xmlStartTag('User', array('Action' => 'Insert'));
48  $new_name = ilAuthUtils::_generateLogin($a_username);
49  $this->writer->xmlElement('Login', array(), $new_name);
50 
51  // Assign to role only for new users
52  $this->writer->xmlElement(
53  'Role',
54  array(
55  'Id' => $this->settings->getDefaultRole(),
56  'Type' => 'Global',
57  'Action' => 'Assign'),
58  ''
59  );
60 
61  $this->writer->xmlElement('Active', array(), "true");
62  $this->writer->xmlElement('TimeLimitOwner', array(), 7);
63  $this->writer->xmlElement('TimeLimitUnlimited', array(), 1);
64  $this->writer->xmlElement('TimeLimitFrom', array(), time());
65  $this->writer->xmlElement('TimeLimitUntil', array(), time());
66  $this->writer->xmlElement('AuthMode', array('type' => 'cas'), 'cas');
67  $this->writer->xmlElement('ExternalAccount', array(), $a_username);
68 
69  $this->writer->xmlEndTag('User');
70  $this->writer->xmlEndTag('Users');
71 
72  $this->logger->info('CAS: Startet creation of user: ' . $new_name);
73 
74  $importParser = new ilUserImportParser();
75  $importParser->setXMLContent($this->writer->xmlDumpMem(false));
76  $importParser->setRoleAssignment(
77  array(
78  $this->settings->getDefaultRole() => $this->settings->getDefaultRole()
79  )
80  );
81  //TODO check if there is a constant
82  $importParser->setFolderId(7);
83  $importParser->startParsing();
84 
85  return $new_name;
86  }
static _generateLogin(string $a_login)
generate free login by starting with a default string and adding postfix numbers
+ Here is the call graph for this function:

Field Documentation

◆ $logger

ilLogger ilCASAttributeToUser::$logger
private

Definition at line 28 of file class.ilCASAttributeToUser.php.

◆ $settings

ilCASSettings ilCASAttributeToUser::$settings
private

Definition at line 30 of file class.ilCASAttributeToUser.php.

Referenced by __construct().

◆ $writer

ilXmlWriter ilCASAttributeToUser::$writer
private

Definition at line 29 of file class.ilCASAttributeToUser.php.


The documentation for this class was generated from the following file: