19declare(strict_types=1);
37 $this->
logger = $DIC->logger()->auth();
38 $this->cronManager =
$DIC->cron()->manager();
39 $this->
lng = $DIC->language();
40 $this->
lng->loadLanguageModule(
'ldap');
50 return $this->
lng->txt(
'ldap_user_sync_cron');
55 return $this->
lng->txt(
"ldap_user_sync_cron_info");
86 $current_server->doConnectionCheck();
87 $this->
logger->info(
"LDAP: starting user synchronization for " . $current_server->getName());
92 if (is_array($users = $ldap_query->fetchUsers())) {
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);
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");
113 $this->cronManager->ping($this->
getId());
117 $this->
logger->info(
"LDAP: No users for update/create. Aborting.");
120 $mess = $exc->getMessage();
121 $this->
logger->info($mess);
127 if ($this->counter) {
132 $result->setMessage(implode(
"\n",
$messages));
134 $result->setStatus($status);
146 if (!array_key_exists($external_account, $a_ldap_users)) {
147 $inactive[] = $usr_id;
150 if (count($inactive)) {
152 $this->
logger->info(
'LDAP: Found ' . count($inactive) .
' inactive users.');
156 $this->
logger->info(
'LDAP: No inactive users found');
163 $a_fields[
"ldap_user_sync_cron"] = [$a_is_active ?
164 $this->
lng->txt(
"enabled") :
165 $this->
lng->txt(
"disabled"),
const SCHEDULE_TYPE_DAILY
@depracated This will be replaced with an ENUM in ILIAS 9
Update/create ILIAS user account by given LDAP attributes according to user attribute mapping setting...
hasAutoActivation()
Is to be activated on "installation", does only work for ILIAS core cron jobs.
getDefaultScheduleValue()
addToExternalSettingsForm(int $a_form_id, array &$a_fields, bool $a_is_active)
ilCronManager $cronManager
deactivateUsers(ilLDAPServer $server, array $a_ldap_users)
Deactivate users that are disabled in LDAP.
static _getCronServerIds()
Get list of acticve servers with option 'SyncCron'.
Component logger with individual log levels by component id.
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...
$messages
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...