ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 ILIAS\Cron\CronJob
 setDateTimeProvider (?\Closure $date_time_provider)
 
 isDue (?\DateTimeImmutable $last_run, ?JobScheduleType $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 (?JobScheduleType $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 ()
 
 usesLegacyForms ()
 
 getCustomConfigurationInput (\ILIAS\UI\Factory $ui_factory, \ILIAS\Refinery\Factory $factory, \ilLanguage $lng)
 
 addCustomSettingsToForm (\ilPropertyFormGUI $a_form)
 
 saveCustomConfiguration (mixed $form_data)
 
 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
 
JobManager $cronManager
 
int $counter = 0
 

Additional Inherited Members

- Protected Attributes inherited from ILIAS\Cron\CronJob
JobScheduleType $schedule_type = null
 
int $schedule_value = null
 
Closure $date_time_provider = null
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilLDAPCronSynchronization::__construct ( )

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

39 {
40 global $DIC;
41
42 $this->logger = $DIC->logger()->auth();
43 $this->cronManager = $DIC->cron()->manager();
44 $this->lng = $DIC->language();
45 $this->lng->loadLanguageModule('ldap');
46 }
global $DIC
Definition: shib_login.php:26

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 
)
Parameters
array<string,mixed>$a_fields

Reimplemented from ILIAS\Cron\CronJob.

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

165 : void
166 {
168 $a_fields["ldap_user_sync_cron"] = [$a_is_active ?
169 $this->lng->txt("enabled") :
170 $this->lng->txt("disabled"),
172 }
173 }

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 146 of file class.ilLDAPCronSynchronization.php.

146 : void
147 {
148 $inactive = [];
149
150 foreach (ilObjUser::_getExternalAccountsByAuthMode($server->getAuthenticationMappingKey(), true) as $usr_id => $external_account) {
151 if (!array_key_exists($external_account, $a_ldap_users)) {
152 $inactive[] = $usr_id;
153 }
154 }
155 if (count($inactive)) {
157 $this->logger->info('LDAP: Found ' . count($inactive) . ' inactive users.');
158
159 $this->counter++;
160 } else {
161 $this->logger->info('LDAP: No inactive users found');
162 }
163 }
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
Definition: shib_login.php:28

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 ILIAS\Cron\CronJob.

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

64 {
65 return JobScheduleType::DAILY;
66 }

◆ getDefaultScheduleValue()

ilLDAPCronSynchronization::getDefaultScheduleValue ( )

Reimplemented from ILIAS\Cron\CronJob.

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

68 : ?int
69 {
70 return null;
71 }

◆ getDescription()

ilLDAPCronSynchronization::getDescription ( )

Reimplemented from ILIAS\Cron\CronJob.

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

58 : string
59 {
60 return $this->lng->txt("ldap_user_sync_cron_info");
61 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getId()

ilLDAPCronSynchronization::getId ( )

Reimplemented from ILIAS\Cron\CronJob.

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

48 : string
49 {
50 return "ldap_sync";
51 }

Referenced by run().

+ Here is the caller graph for this function:

◆ getTitle()

ilLDAPCronSynchronization::getTitle ( )

Reimplemented from ILIAS\Cron\CronJob.

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

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

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 ILIAS\Cron\CronJob.

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

73 : bool
74 {
75 return false;
76 }

◆ hasFlexibleSchedule()

ilLDAPCronSynchronization::hasFlexibleSchedule ( )

Reimplemented from ILIAS\Cron\CronJob.

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

78 : bool
79 {
80 return false;
81 }

◆ run()

ilLDAPCronSynchronization::run ( )

Reimplemented from ILIAS\Cron\CronJob.

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

83 : JobResult
84 {
85 $status = JobResult::STATUS_NO_ACTION;
86
87 $messages = array();
88 foreach (ilLDAPServer::_getCronServerIds() as $server_id) {
89 try {
90 $current_server = new ilLDAPServer($server_id);
91 $current_server->doConnectionCheck();
92 $this->logger->info("LDAP: starting user synchronization for " . $current_server->getName());
93
94 $ldap_query = new ilLDAPQuery($current_server);
95 $ldap_query->bind();
96
97 if (is_array($users = $ldap_query->fetchUsers())) {
98 // Deactivate ldap users that are not in the list
99 $this->deactivateUsers($current_server, $users);
100 }
101
102 if (count($users)) {
104
105 $offset = 0;
106 $limit = 500;
107 while ($user_sliced = array_slice($users, $offset, $limit, true)) {
108 $this->logger->info("LDAP: Starting update/creation of users ...");
109 $this->logger->info("LDAP: Offset: " . $offset);
110 $ldap_to_ilias = new ilLDAPAttributeToUser($current_server);
111 $ldap_to_ilias->setNewUserAuthMode($current_server->getAuthenticationMappingKey());
112 $ldap_to_ilias->setUserData($user_sliced);
113 $ldap_to_ilias->refresh();
114 $this->logger->info("LDAP: Finished update/creation");
115
116 $offset += $limit;
117
118 $this->cronManager->ping($this->getId());
119 }
120 $this->counter++;
121 } else {
122 $this->logger->info("LDAP: No users for update/create. Aborting.");
123 }
124 } catch (ilLDAPQueryException $exc) {
125 $mess = $exc->getMessage();
126 $this->logger->info($mess);
127
128 $messages[] = $mess;
129 }
130 }
131
132 if ($this->counter) {
133 $status = JobResult::STATUS_OK;
134 }
135 $result = new JobResult();
136 if (count($messages)) {
137 $result->setMessage(implode("\n", $messages));
138 }
139 $result->setStatus($status);
140 return $result;
141 }
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
Definition: xapiexit.php:21

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

+ Here is the call graph for this function:

Field Documentation

◆ $counter

int ilLDAPCronSynchronization::$counter = 0
private

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

◆ $cronManager

JobManager ilLDAPCronSynchronization::$cronManager
private

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

◆ $lng

ilLanguage ilLDAPCronSynchronization::$lng
private

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

◆ $logger

ilLogger ilLDAPCronSynchronization::$logger
private

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


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