19 declare(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");
60 return self::SCHEDULE_TYPE_DAILY;
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"),
ilCronManager $cronManager
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...
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.
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.