ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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.

@access public

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

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 }
XML writer class.
settings()
Definition: settings.php:2
global $DIC

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

+ Here is the call graph for this function:

Member Function Documentation

◆ create()

ilCASAttributeToUser::create (   $a_username)

Create new ILIAS account.

@access public

Parameters
stringexternal username

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

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 }
static _generateLogin($a_login)
generate free login by starting with a default string and adding postfix numbers

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

+ 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: