ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilLDAPCronSynchronization Class Reference
+ Inheritance diagram for ilLDAPCronSynchronization:
+ Collaboration diagram for ilLDAPCronSynchronization:

Public Member Functions

 getId ()
 
 getTitle ()
 
 getDescription ()
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
 hasAutoActivation ()
 
 hasFlexibleSchedule ()
 
 run ()
 
 addToExternalSettingsForm ($a_form_id, array &$a_fields, $a_is_active)
 
- 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 
)

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

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

162  {
163  global $DIC;
164 
165  $lng = $DIC['lng'];
166 
167  switch ($a_form_id) {
169  $a_fields["ldap_user_sync_cron"] = $a_is_active ?
170  $lng->txt("enabled") :
171  $lng->txt("disabled");
172  break;
173  }
174  }
global $DIC
Definition: saml.php:7
$lng

◆ 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.

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

Referenced by run().

138  {
139  global $DIC;
140 
141  $ilLog = $DIC['ilLog'];
142 
143  include_once './Services/User/classes/class.ilObjUser.php';
144 
145  $inactive = [];
146  foreach ($ext = ilObjUser::_getExternalAccountsByAuthMode($server->getAuthenticationMappingKey(), true) as $usr_id => $external_account) {
147  if (!array_key_exists($external_account, $a_ldap_users)) {
148  $inactive[] = $usr_id;
149  }
150  }
151  if (count($inactive)) {
152  ilObjUser::_toggleActiveStatusOfUsers($inactive, false);
153  $ilLog->write('LDAP: Found ' . count($inactive) . ' inactive users.');
154 
155  $this->counter++;
156  } else {
157  $ilLog->write('LDAP: No inactive users found');
158  }
159  }
global $DIC
Definition: saml.php:7
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...
static _toggleActiveStatusOfUsers($a_usr_ids, $a_status)
Toggle active status of users.
getAuthenticationMappingKey()
Get authentication mapping key Default is ldap.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDefaultScheduleType()

ilLDAPCronSynchronization::getDefaultScheduleType ( )

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

50  {
51  return self::SCHEDULE_TYPE_DAILY;
52  }

◆ getDefaultScheduleValue()

ilLDAPCronSynchronization::getDefaultScheduleValue ( )

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

55  {
56  return;
57  }

◆ getDescription()

ilLDAPCronSynchronization::getDescription ( )

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

References $DIC, and $lng.

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

◆ getId()

ilLDAPCronSynchronization::getId ( )

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

Referenced by run().

25  {
26  return "ldap_sync";
27  }
+ Here is the caller graph for this function:

◆ getTitle()

ilLDAPCronSynchronization::getTitle ( )

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

References $DIC, and $lng.

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

◆ hasAutoActivation()

ilLDAPCronSynchronization::hasAutoActivation ( )

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

60  {
61  return false;
62  }

◆ hasFlexibleSchedule()

ilLDAPCronSynchronization::hasFlexibleSchedule ( )

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

65  {
66  return false;
67  }

◆ run()

ilLDAPCronSynchronization::run ( )

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

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

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) {
124  $status = ilCronJobResult::STATUS_OK;
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
global $DIC
Definition: saml.php:7
static getInstance()
Get instance.
const IL_LDAP_BIND_DEFAULT
$messages
Definition: en.php:5
deactivateUsers(ilLDAPServer $server, $a_ldap_users)
Deactivate users that are disabled in LDAP.
static _getCronServerIds()
Get list of acticve servers with option 'SyncCron'.
$users
Definition: authpage.php:44
static ping($a_job_id)
Keep cron job alive.
Update/create ILIAS user account by given LDAP attributes according to user attribute mapping setting...
Cron job result data container.
+ 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: