19declare(strict_types=1);
42 $this->
logger = $DIC->logger()->auth();
43 $this->cronManager =
$DIC->cron()->manager();
44 $this->
lng = $DIC->language();
45 $this->
lng->loadLanguageModule(
'ldap');
55 return $this->
lng->txt(
'ldap_user_sync_cron');
60 return $this->
lng->txt(
"ldap_user_sync_cron_info");
65 return JobScheduleType::DAILY;
85 $status = JobResult::STATUS_NO_ACTION;
91 $current_server->doConnectionCheck();
92 $this->
logger->info(
"LDAP: starting user synchronization for " . $current_server->getName());
97 if (is_array($users = $ldap_query->fetchUsers())) {
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);
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");
118 $this->cronManager->ping($this->
getId());
122 $this->
logger->info(
"LDAP: No users for update/create. Aborting.");
125 $mess = $exc->getMessage();
126 $this->
logger->info($mess);
132 if ($this->counter) {
133 $status = JobResult::STATUS_OK;
137 $result->setMessage(implode(
"\n",
$messages));
139 $result->setStatus($status);
151 if (!array_key_exists($external_account, $a_ldap_users)) {
152 $inactive[] = $usr_id;
155 if (count($inactive)) {
157 $this->
logger->info(
'LDAP: Found ' . count($inactive) .
' inactive users.');
161 $this->
logger->info(
'LDAP: No inactive users found');
168 $a_fields[
"ldap_user_sync_cron"] = [$a_is_active ?
169 $this->
lng->txt(
"enabled") :
170 $this->
lng->txt(
"disabled"),
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)
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...