ILIAS  release_8 Revision v8.25-1-g13de6a5eca6
ilLDAPCronSynchronization Class Reference
+ Inheritance diagram for ilLDAPCronSynchronization:
+ Collaboration diagram for ilLDAPCronSynchronization:

Public Member Functions

 __construct ()
 
 getId ()
 
 getTitle ()
 
 getDescription ()
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
 hasAutoActivation ()
 Is to be activated on "installation", does only work for ILIAS core cron jobs. More...
 
 hasFlexibleSchedule ()
 
 run ()
 
 addToExternalSettingsForm (int $a_form_id, array &$a_fields, bool $a_is_active)
 
- Public Member Functions inherited from ilCronJob
 setDateTimeProvider (?Closure $date_time_provider)
 
 isDue (?DateTimeImmutable $last_run, ?int $schedule_type, ?int $schedule_value, bool $is_manually_executed=false)
 
 getScheduleType ()
 Get current schedule type (if flexible) More...
 
 getScheduleValue ()
 Get current schedule value (if flexible) More...
 
 setSchedule (?int $a_type, ?int $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...
 
 isManuallyExecutable ()
 
 hasCustomSettings ()
 
 addCustomSettingsToForm (ilPropertyFormGUI $a_form)
 
 saveCustomSettings (ilPropertyFormGUI $a_form)
 
 addToExternalSettingsForm (int $a_form_id, array &$a_fields, bool $a_is_active)
 
 activationWasToggled (ilDBInterface $db, ilSetting $setting, bool $a_currently_active)
 Important: This method is (also) called from the setup process, where the constructor of an ilCronJob ist NOT executed. More...
 
 getId ()
 
 getTitle ()
 
 getDescription ()
 
 hasAutoActivation ()
 Is to be activated on "installation", does only work for ILIAS core cron jobs. More...
 
 hasFlexibleSchedule ()
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
 run ()
 

Private Member Functions

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

Private Attributes

ilLanguage $lng
 
ilLogger $logger
 
ilCronManager $cronManager
 
int $counter = 0
 

Additional Inherited Members

- Data Fields inherited from ilCronJob
const SCHEDULE_TYPE_DAILY = 1
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_IN_MINUTES = 2
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_IN_HOURS = 3
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_IN_DAYS = 4
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_WEEKLY = 5
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_MONTHLY = 6
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_QUARTERLY = 7
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_YEARLY = 8
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
- Protected Attributes inherited from ilCronJob
int $schedule_type = null
 
int $schedule_value = null
 
Closure $date_time_provider = null
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilLDAPCronSynchronization::__construct ( )

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

34 {
35 global $DIC;
36
37 $this->logger = $DIC->logger()->auth();
38 $this->cronManager = $DIC->cron()->manager();
39 $this->lng = $DIC->language();
40 $this->lng->loadLanguageModule('ldap');
41 }
global $DIC
Definition: feed.php:28

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

+ Here is the call graph for this function:

Member Function Documentation

◆ addToExternalSettingsForm()

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

Reimplemented from ilCronJob.

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

160 : void
161 {
163 $a_fields["ldap_user_sync_cron"] = [$a_is_active ?
164 $this->lng->txt("enabled") :
165 $this->lng->txt("disabled"),
167 }
168 }

References ilAdministrationSettingsFormHandler\FORM_LDAP, ILIAS\Repository\lng(), and ilAdministrationSettingsFormHandler\VALUE_BOOL.

+ Here is the call graph for this function:

◆ deactivateUsers()

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

Deactivate users that are disabled in LDAP.

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

141 : void
142 {
143 $inactive = [];
144
145 foreach (ilObjUser::_getExternalAccountsByAuthMode($server->getAuthenticationMappingKey(), true) as $usr_id => $external_account) {
146 if (!array_key_exists($external_account, $a_ldap_users)) {
147 $inactive[] = $usr_id;
148 }
149 }
150 if (count($inactive)) {
152 $this->logger->info('LDAP: Found ' . count($inactive) . ' inactive users.');
153
154 $this->counter++;
155 } else {
156 $this->logger->info('LDAP: No inactive users found');
157 }
158 }
static _toggleActiveStatusOfUsers(array $a_usr_ids, bool $a_status)
static _getExternalAccountsByAuthMode(string $a_auth_mode, bool $a_read_auth_default=false)
Get list of external account by authentication method Note: If login == ext_account for two user with...
$server

References $server, ilObjUser\_getExternalAccountsByAuthMode(), ilObjUser\_toggleActiveStatusOfUsers(), and ILIAS\Repository\logger().

Referenced by run().

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

◆ getDefaultScheduleType()

ilLDAPCronSynchronization::getDefaultScheduleType ( )

Reimplemented from ilCronJob.

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

58 : int
59 {
61 }
const SCHEDULE_TYPE_DAILY
@depracated This will be replaced with an ENUM in ILIAS 9

References ilCronJob\SCHEDULE_TYPE_DAILY.

◆ getDefaultScheduleValue()

ilLDAPCronSynchronization::getDefaultScheduleValue ( )

Reimplemented from ilCronJob.

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

63 : ?int
64 {
65 return null;
66 }

◆ getDescription()

ilLDAPCronSynchronization::getDescription ( )

Reimplemented from ilCronJob.

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

53 : string
54 {
55 return $this->lng->txt("ldap_user_sync_cron_info");
56 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getId()

ilLDAPCronSynchronization::getId ( )

Reimplemented from ilCronJob.

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

43 : string
44 {
45 return "ldap_sync";
46 }

Referenced by run().

+ Here is the caller graph for this function:

◆ getTitle()

ilLDAPCronSynchronization::getTitle ( )

Reimplemented from ilCronJob.

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

48 : string
49 {
50 return $this->lng->txt('ldap_user_sync_cron');
51 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ hasAutoActivation()

ilLDAPCronSynchronization::hasAutoActivation ( )

Is to be activated on "installation", does only work for ILIAS core cron jobs.

Reimplemented from ilCronJob.

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

68 : bool
69 {
70 return false;
71 }

◆ hasFlexibleSchedule()

ilLDAPCronSynchronization::hasFlexibleSchedule ( )

Reimplemented from ilCronJob.

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

73 : bool
74 {
75 return false;
76 }

◆ run()

ilLDAPCronSynchronization::run ( )

Reimplemented from ilCronJob.

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

79 {
81
82 $messages = array();
83 foreach (ilLDAPServer::_getCronServerIds() as $server_id) {
84 try {
85 $current_server = new ilLDAPServer($server_id);
86 $current_server->doConnectionCheck();
87 $this->logger->info("LDAP: starting user synchronization for " . $current_server->getName());
88
89 $ldap_query = new ilLDAPQuery($current_server);
90 $ldap_query->bind();
91
92 if (is_array($users = $ldap_query->fetchUsers())) {
93 // Deactivate ldap users that are not in the list
94 $this->deactivateUsers($current_server, $users);
95 }
96
97 if (count($users)) {
99
100 $offset = 0;
101 $limit = 500;
102 while ($user_sliced = array_slice($users, $offset, $limit, true)) {
103 $this->logger->info("LDAP: Starting update/creation of users ...");
104 $this->logger->info("LDAP: Offset: " . $offset);
105 $ldap_to_ilias = new ilLDAPAttributeToUser($current_server);
106 $ldap_to_ilias->setNewUserAuthMode($current_server->getAuthenticationMappingKey());
107 $ldap_to_ilias->setUserData($user_sliced);
108 $ldap_to_ilias->refresh();
109 $this->logger->info("LDAP: Finished update/creation");
110
111 $offset += $limit;
112
113 $this->cronManager->ping($this->getId());
114 }
115 $this->counter++;
116 } else {
117 $this->logger->info("LDAP: No users for update/create. Aborting.");
118 }
119 } catch (ilLDAPQueryException $exc) {
120 $mess = $exc->getMessage();
121 $this->logger->info($mess);
122
123 $messages[] = $mess;
124 }
125 }
126
127 if ($this->counter) {
129 }
130 $result = new ilCronJobResult();
131 if (count($messages)) {
132 $result->setMessage(implode("\n", $messages));
133 }
134 $result->setStatus($status);
135 return $result;
136 }
Update/create ILIAS user account by given LDAP attributes according to user attribute mapping setting...
deactivateUsers(ilLDAPServer $server, array $a_ldap_users)
Deactivate users that are disabled in LDAP.
static _getCronServerIds()
Get list of acticve servers with option 'SyncCron'.
$messages
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: xapiexit.php:22

References $messages, ilLDAPServer\_getCronServerIds(), ilUserCreationContext\CONTEXT_LDAP, deactivateUsers(), getId(), ilUserCreationContext\getInstance(), ILIAS\Repository\logger(), ilCronJobResult\STATUS_NO_ACTION, and ilCronJobResult\STATUS_OK.

+ Here is the call graph for this function:

Field Documentation

◆ $counter

int ilLDAPCronSynchronization::$counter = 0
private

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

◆ $cronManager

ilCronManager ilLDAPCronSynchronization::$cronManager
private

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

◆ $lng

ilLanguage ilLDAPCronSynchronization::$lng
private

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

◆ $logger

ilLogger ilLDAPCronSynchronization::$logger
private

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


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