3 declare(strict_types=1);
39 $this->
logger = $DIC->logger()->auth();
40 $this->cronManager = $DIC->cron()->manager();
41 $this->
lng = $DIC->language();
42 $this->
lng->loadLanguageModule(
'ldap');
52 return $this->
lng->txt(
'ldap_user_sync_cron');
57 return $this->
lng->txt(
"ldap_user_sync_cron_info");
62 return CronJobScheduleType::SCHEDULE_TYPE_DAILY;
88 $current_server->doConnectionCheck();
89 $this->
logger->info(
"LDAP: starting user synchronization for " . $current_server->getName());
94 if (is_array($users = $ldap_query->fetchUsers())) {
104 while ($user_sliced = array_slice($users, $offset, $limit,
true)) {
105 $this->
logger->info(
"LDAP: Starting update/creation of users ...");
106 $this->
logger->info(
"LDAP: Offset: " . $offset);
108 $ldap_to_ilias->setNewUserAuthMode($current_server->getAuthenticationMappingKey());
109 $ldap_to_ilias->setUserData($user_sliced);
110 $ldap_to_ilias->refresh();
111 $this->
logger->info(
"LDAP: Finished update/creation");
115 $this->cronManager->ping($this->
getId());
119 $this->
logger->info(
"LDAP: No users for update/create. Aborting.");
122 $mess = $exc->getMessage();
123 $this->
logger->info($mess);
129 if ($this->counter) {
134 $result->setMessage(implode(
"\n",
$messages));
136 $result->setStatus($status);
148 if (!array_key_exists($external_account, $a_ldap_users)) {
149 $inactive[] = $usr_id;
152 if (count($inactive)) {
154 $this->
logger->info(
'LDAP: Found ' . count($inactive) .
' inactive users.');
158 $this->
logger->info(
'LDAP: No inactive users found');
165 $a_fields[
"ldap_user_sync_cron"] = [$a_is_active ?
166 $this->
lng->txt(
"enabled") :
167 $this->
lng->txt(
"disabled"),
ilCronManager $cronManager
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getDefaultScheduleValue()
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...
$messages
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
final const STATUS_NO_ACTION
static _toggleActiveStatusOfUsers(array $a_usr_ids, bool $a_status)
static _getCronServerIds()
Get list of acticve servers with option 'SyncCron'.
addToExternalSettingsForm(int $a_form_id, array &$a_fields, bool $a_is_active)
getAuthenticationMappingKey()
Get authentication mapping key Default is ldap.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
deactivateUsers(ilLDAPServer $server, array $a_ldap_users)
Deactivate users that are disabled in LDAP.