ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilLDAPCronSynchronization Class Reference
+ Inheritance diagram for ilLDAPCronSynchronization:
+ Collaboration diagram for ilLDAPCronSynchronization:

Public Member Functions

 getId ()
 Get id. More...
 
 getTitle ()
 Get title. More...
 
 getDescription ()
 Get description. More...
 
 getDefaultScheduleType ()
 Get schedule type. More...
 
 getDefaultScheduleValue ()
 Get schedule value. More...
 
 hasAutoActivation ()
 Is to be activated on "installation". More...
 
 hasFlexibleSchedule ()
 Can the schedule be configured? More...
 
 run ()
 Run job. More...
 
 addToExternalSettingsForm ($a_form_id, array &$a_fields, $a_is_active)
 Add external settings to form. More...
 
- Public Member Functions inherited from ilCronJob
 isActive ($a_ts_last_run, $a_schedule_type, $a_schedule_value, $a_manual=false)
 Is job currently active? More...
 
 getScheduleType ()
 Get current schedule type (if flexible) More...
 
 getScheduleValue ()
 Get current schedule value (if flexible) More...
 
 setSchedule ($a_type, $a_value)
 Update current schedule (if flexible) More...
 
 getAllScheduleTypes ()
 Get all available schedule types. More...
 
 getScheduleTypesWithValues ()
 
 getValidScheduleTypes ()
 Returns a collection of all valid schedule types for a specific job. More...
 
 getTitle ()
 Get title. More...
 
 getDescription ()
 Get description. More...
 
 isManuallyExecutable ()
 Defines whether or not a cron job can be started manually. More...
 
 hasCustomSettings ()
 Has cron job any custom setting which can be edited? More...
 
 addCustomSettingsToForm (ilPropertyFormGUI $a_form)
 Add custom settings to form. More...
 
 saveCustomSettings (ilPropertyFormGUI $a_form)
 Save custom settings. More...
 
 addToExternalSettingsForm ($a_form_id, array &$a_fields, $a_is_active)
 Add external settings to form. More...
 
 activationWasToggled ($a_currently_active)
 Cron job status was changed. More...
 
 getId ()
 Get id. More...
 
 hasAutoActivation ()
 Is to be activated on "installation". More...
 
 hasFlexibleSchedule ()
 Can the schedule be configured? More...
 
 getDefaultScheduleType ()
 Get schedule type. More...
 
 getDefaultScheduleValue ()
 Get schedule value. More...
 
 run ()
 Run job. More...
 

Private Member Functions

 deactivateUsers (ilLDAPServer $server, $a_ldap_users)
 Deactivate users that are disabled in LDAP. More...
 

Private Attributes

 $current_server = null
 
 $ldap_query = null
 
 $ldap_to_ilias = null
 
 $counter = 0
 

Additional Inherited Members

- Data Fields inherited from ilCronJob
const SCHEDULE_TYPE_DAILY = 1
 
const SCHEDULE_TYPE_IN_MINUTES = 2
 
const SCHEDULE_TYPE_IN_HOURS = 3
 
const SCHEDULE_TYPE_IN_DAYS = 4
 
const SCHEDULE_TYPE_WEEKLY = 5
 
const SCHEDULE_TYPE_MONTHLY = 6
 
const SCHEDULE_TYPE_QUARTERLY = 7
 
const SCHEDULE_TYPE_YEARLY = 8
 
- Protected Member Functions inherited from ilCronJob
 checkSchedule ($a_ts_last_run, $a_schedule_type, $a_schedule_value)
 

Detailed Description

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 17 of file class.ilLDAPCronSynchronization.php.

Member Function Documentation

◆ addToExternalSettingsForm()

ilLDAPCronSynchronization::addToExternalSettingsForm (   $a_form_id,
array &  $a_fields,
  $a_is_active 
)

Add external settings to form.

Parameters
int$a_form_id
array$a_fields
bool$a_is_active

Reimplemented from ilCronJob.

Definition at line 163 of file class.ilLDAPCronSynchronization.php.

164 {
165 global $DIC;
166
167 $lng = $DIC['lng'];
168
169 switch ($a_form_id) {
171 $a_fields["ldap_user_sync_cron"] = $a_is_active ?
172 $lng->txt("enabled") :
173 $lng->txt("disabled");
174 break;
175 }
176 }
$lng
$DIC
Definition: xapitoken.php:46

References $DIC, $lng, and ilAdministrationSettingsFormHandler\FORM_LDAP.

◆ deactivateUsers()

ilLDAPCronSynchronization::deactivateUsers ( ilLDAPServer  $server,
  $a_ldap_users 
)
private

Deactivate users that are disabled in LDAP.

Definition at line 137 of file class.ilLDAPCronSynchronization.php.

138 {
139 global $DIC;
140
141 $ilLog = $DIC['ilLog'];
142
143 include_once './Services/User/classes/class.ilObjUser.php';
144
145
146 $inactive = [];
147
148 foreach ($ext = ilObjUser::_getExternalAccountsByAuthMode($server->getAuthenticationMappingKey(), true) as $usr_id => $external_account) {
149 if (!array_key_exists($external_account, $a_ldap_users)) {
150 $inactive[] = $usr_id;
151 }
152 }
153 if (count($inactive)) {
155 $ilLog->write('LDAP: Found ' . count($inactive) . ' inactive users.');
156
157 $this->counter++;
158 } else {
159 $ilLog->write('LDAP: No inactive users found');
160 }
161 }
static _toggleActiveStatusOfUsers($a_usr_ids, $a_status)
Toggle active status of users.
static _getExternalAccountsByAuthMode($a_auth_mode, $a_read_auth_default=false)
Get list of external account by authentication method Note: If login == ext_account for two user with...
$server

References $DIC, $ilLog, $server, ilObjUser\_getExternalAccountsByAuthMode(), and ilObjUser\_toggleActiveStatusOfUsers().

Referenced by run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDefaultScheduleType()

ilLDAPCronSynchronization::getDefaultScheduleType ( )

Get schedule type.

Returns
int

Reimplemented from ilCronJob.

Definition at line 49 of file class.ilLDAPCronSynchronization.php.

50 {
52 }
const SCHEDULE_TYPE_DAILY

References ilCronJob\SCHEDULE_TYPE_DAILY.

◆ getDefaultScheduleValue()

ilLDAPCronSynchronization::getDefaultScheduleValue ( )

Get schedule value.

Returns
int|array

Reimplemented from ilCronJob.

Definition at line 54 of file class.ilLDAPCronSynchronization.php.

55 {
56 return;
57 }

◆ getDescription()

ilLDAPCronSynchronization::getDescription ( )

Get description.

Returns
string

Reimplemented from ilCronJob.

Definition at line 39 of file class.ilLDAPCronSynchronization.php.

40 {
41 global $DIC;
42
43 $lng = $DIC['lng'];
44
45 $lng->loadLanguageModule("ldap");
46 return $lng->txt("ldap_user_sync_cron_info");
47 }

References $DIC, and $lng.

◆ getId()

ilLDAPCronSynchronization::getId ( )

Get id.

Returns
string

Reimplemented from ilCronJob.

Definition at line 24 of file class.ilLDAPCronSynchronization.php.

25 {
26 return "ldap_sync";
27 }

Referenced by run().

+ Here is the caller graph for this function:

◆ getTitle()

ilLDAPCronSynchronization::getTitle ( )

Get title.

Returns
string

Reimplemented from ilCronJob.

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

30 {
31 global $DIC;
32
33 $lng = $DIC['lng'];
34
35 $lng->loadLanguageModule('ldap');
36 return $lng->txt('ldap_user_sync_cron');
37 }

References $DIC, and $lng.

◆ hasAutoActivation()

ilLDAPCronSynchronization::hasAutoActivation ( )

Is to be activated on "installation".

Returns
boolean

Reimplemented from ilCronJob.

Definition at line 59 of file class.ilLDAPCronSynchronization.php.

60 {
61 return false;
62 }

◆ hasFlexibleSchedule()

ilLDAPCronSynchronization::hasFlexibleSchedule ( )

Can the schedule be configured?

Returns
boolean

Reimplemented from ilCronJob.

Definition at line 64 of file class.ilLDAPCronSynchronization.php.

65 {
66 return false;
67 }

◆ run()

ilLDAPCronSynchronization::run ( )

Run job.

Returns
ilCronJobResult

Reimplemented from ilCronJob.

Definition at line 69 of file class.ilLDAPCronSynchronization.php.

70 {
71 global $DIC;
72
73 $ilLog = $DIC['ilLog'];
74
76
77 $messages = array();
78 foreach (ilLDAPServer::_getCronServerIds() as $server_id) {
79 try {
80 $this->current_server = new ilLDAPServer($server_id);
81 $this->current_server->doConnectionCheck();
82 $ilLog->write("LDAP: starting user synchronization for " . $this->current_server->getName());
83
84 $this->ldap_query = new ilLDAPQuery($this->current_server);
85 $this->ldap_query->bind(IL_LDAP_BIND_DEFAULT);
86
87 if (is_array($users = $this->ldap_query->fetchUsers())) {
88 // Deactivate ldap users that are not in the list
89 $this->deactivateUsers($this->current_server, $users);
90 }
91
92 if (count($users)) {
93 include_once './Services/User/classes/class.ilUserCreationContext.php';
95
96 $offset = 0;
97 $limit = 500;
98 while ($user_sliced = array_slice($users, $offset, $limit, true)) {
99 $ilLog->write("LDAP: Starting update/creation of users ...");
100 $ilLog->write("LDAP: Offset: " . $offset);
101 $this->ldap_to_ilias = new ilLDAPAttributeToUser($this->current_server);
102 $this->ldap_to_ilias->setNewUserAuthMode($this->current_server->getAuthenticationMappingKey());
103 $this->ldap_to_ilias->setUserData($user_sliced);
104 $this->ldap_to_ilias->refresh();
105 $ilLog->write("LDAP: Finished update/creation");
106
107 $offset += $limit;
108
109 ilCronManager::ping($this->getId());
110 }
111 $this->counter++;
112 } else {
113 $ilLog->write("LDAP: No users for update/create. Aborting.");
114 }
115 } catch (ilLDAPQueryException $exc) {
116 $mess = $exc->getMessage();
117 $ilLog->write($mess);
118
119 $messages[] = $mess;
120 }
121 }
122
123 if ($this->counter) {
125 }
126 $result = new ilCronJobResult();
127 if (sizeof($messages)) {
128 $result->setMessage(implode("\n", $messages));
129 }
130 $result->setStatus($status);
131 return $result;
132 }
$result
const IL_LDAP_BIND_DEFAULT
Cron job result data container.
static ping($a_job_id)
Keep cron job alive.
Update/create ILIAS user account by given LDAP attributes according to user attribute mapping setting...
deactivateUsers(ilLDAPServer $server, $a_ldap_users)
Deactivate users that are disabled in LDAP.
static _getCronServerIds()
Get list of acticve servers with option 'SyncCron'.
static getInstance()
Get instance.
$messages
Definition: xapiexit.php:5

References $DIC, $ilLog, $messages, $result, ilLDAPServer\_getCronServerIds(), ilUserCreationContext\CONTEXT_LDAP, deactivateUsers(), getId(), ilUserCreationContext\getInstance(), IL_LDAP_BIND_DEFAULT, ilCronManager\ping(), ilCronJobResult\STATUS_NO_ACTION, and ilCronJobResult\STATUS_OK.

+ Here is the call graph for this function:

Field Documentation

◆ $counter

ilLDAPCronSynchronization::$counter = 0
private

Definition at line 22 of file class.ilLDAPCronSynchronization.php.

◆ $current_server

ilLDAPCronSynchronization::$current_server = null
private

Definition at line 19 of file class.ilLDAPCronSynchronization.php.

◆ $ldap_query

ilLDAPCronSynchronization::$ldap_query = null
private

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

◆ $ldap_to_ilias

ilLDAPCronSynchronization::$ldap_to_ilias = null
private

Definition at line 21 of file class.ilLDAPCronSynchronization.php.


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