ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilCASAttributeToUser Class Reference

CAS user creation helper. More...

+ Collaboration diagram for ilCASAttributeToUser:

Public Member Functions

 __construct (\ilCASSettings $settings)
 Constructor. More...
 
 create ($a_username)
 Create new ILIAS account. More...
 

Private Attributes

 $logger = null
 
 $writer = null
 
 $settings = null
 

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 10 of file class.ilCASAttributeToUser.php.

Constructor & Destructor Documentation

◆ __construct()

ilCASAttributeToUser::__construct ( \ilCASSettings  $settings)

Constructor.

public

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

References $DIC, $settings, and settings().

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  }
global $DIC
Definition: saml.php:7
XML writer class.
settings()
Definition: settings.php:2
+ Here is the call graph for this function:

Member Function Documentation

◆ create()

ilCASAttributeToUser::create (   $a_username)

Create new ILIAS account.

public

Parameters
stringexternal username

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

References ilAuthUtils\_generateLogin(), array, settings(), and time.

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  }
static _generateLogin($a_login)
generate free login by starting with a default string and adding postfix numbers
Create styles array
The data for the language used.
settings()
Definition: settings.php:2
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the call graph for this function:

Field Documentation

◆ $logger

ilCASAttributeToUser::$logger = null
private

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

◆ $settings

ilCASAttributeToUser::$settings = null
private

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

Referenced by __construct().

◆ $writer

ilCASAttributeToUser::$writer = null
private

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


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