ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f87
ilLDAPCronSynchronization Class Reference
+ Inheritance diagram for ilLDAPCronSynchronization:
+ Collaboration diagram for ilLDAPCronSynchronization:

Public Member Functions

 getId ()
 
 getTitle ()
 
 getDescription ()
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
 hasAutoActivation ()
 
 hasFlexibleSchedule ()
 
 run ()
 
 addToExternalSettingsForm ($a_form_id, array &$a_fields, $a_is_active)
 
- Public Member Functions inherited from ilCronJob
 isActive ($a_ts_last_run, $a_schedule_type, $a_schedule_value, $a_manual=false)
 Is job currently active? More...
 
 getScheduleType ()
 Get current schedule type (if flexible) More...
 
 getScheduleValue ()
 Get current schedule value (if flexible) More...
 
 setSchedule ($a_type, $a_value)
 Update current schedule (if flexible) More...
 
 getValidScheduleTypes ()
 Get all available schedule types. More...
 
 getTitle ()
 Get title. More...
 
 getDescription ()
 Get description. More...
 
 isManuallyExecutable ()
 Defines whether or not a cron job can be started manually. More...
 
 hasCustomSettings ()
 Has cron job any custom setting which can be edited? More...
 
 addCustomSettingsToForm (ilPropertyFormGUI $a_form)
 Add custom settings to form. More...
 
 saveCustomSettings (ilPropertyFormGUI $a_form)
 Save custom settings. More...
 
 addToExternalSettingsForm ($a_form_id, array &$a_fields, $a_is_active)
 Add external settings to form. More...
 
 activationWasToggled ($a_currently_active)
 Cron job status was changed. More...
 
 getId ()
 Get id. More...
 
 hasAutoActivation ()
 Is to be activated on "installation". More...
 
 hasFlexibleSchedule ()
 Can the schedule be configured? More...
 
 getDefaultScheduleType ()
 Get schedule type. More...
 
 getDefaultScheduleValue ()
 Get schedule value. More...
 
 run ()
 Run job. More...
 

Private Member Functions

 deactivateUsers (ilLDAPServer $server, $a_ldap_users)
 Deactivate users that are disabled in LDAP. More...
 

Private Attributes

 $current_server = null
 
 $ldap_query = null
 
 $ldap_to_ilias = null
 
 $counter = 0
 

Additional Inherited Members

- Data Fields inherited from ilCronJob
const SCHEDULE_TYPE_DAILY = 1
 
const SCHEDULE_TYPE_IN_MINUTES = 2
 
const SCHEDULE_TYPE_IN_HOURS = 3
 
const SCHEDULE_TYPE_IN_DAYS = 4
 
const SCHEDULE_TYPE_WEEKLY = 5
 
const SCHEDULE_TYPE_MONTHLY = 6
 
const SCHEDULE_TYPE_QUARTERLY = 7
 
const SCHEDULE_TYPE_YEARLY = 8
 
- Protected Member Functions inherited from ilCronJob
 checkSchedule ($a_ts_last_run, $a_schedule_type, $a_schedule_value)
 

Detailed Description

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

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

Member Function Documentation

◆ addToExternalSettingsForm()

ilLDAPCronSynchronization::addToExternalSettingsForm (   $a_form_id,
array &  $a_fields,
  $a_is_active 
)

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

References $lng, and ilAdministrationSettingsFormHandler\FORM_LDAP.

167  {
168  global $lng;
169 
170  switch($a_form_id)
171  {
173  $a_fields["ldap_user_sync_cron"] = $a_is_active ?
174  $lng->txt("enabled") :
175  $lng->txt("disabled");
176  break;
177  }
178  }
global $lng
Definition: privfeed.php:40

◆ deactivateUsers()

ilLDAPCronSynchronization::deactivateUsers ( ilLDAPServer  $server,
  $a_ldap_users 
)
private

Deactivate users that are disabled in LDAP.

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

References $ilLog, ilObjUser\_getExternalAccountsByAuthMode(), ilObjUser\_toggleActiveStatusOfUsers(), and ilLDAPServer\getAuthenticationMappingKey().

Referenced by run().

141  {
142  global $ilLog;
143 
144  include_once './Services/User/classes/class.ilObjUser.php';
145 
146  foreach($ext = ilObjUser::_getExternalAccountsByAuthMode($server->getAuthenticationMappingKey(),true) as $usr_id => $external_account)
147  {
148  if(!array_key_exists($external_account,$a_ldap_users))
149  {
150  $inactive[] = $usr_id;
151  }
152  }
153  if(count($inactive))
154  {
155  ilObjUser::_toggleActiveStatusOfUsers($inactive,false);
156  $ilLog->write('LDAP: Found '.count($inactive).' inactive users.');
157 
158  $this->counter++;
159  }
160  else
161  {
162  $ilLog->write('LDAP: No inactive users found');
163  }
164  }
static _getExternalAccountsByAuthMode($a_auth_mode, $a_read_auth_default=false)
Get list of external account by authentication method Note: If login == ext_account for two user with...
static _toggleActiveStatusOfUsers($a_usr_ids, $a_status)
Toggle active status of users.
getAuthenticationMappingKey()
Get authentication mapping key Default is ldap.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDefaultScheduleType()

ilLDAPCronSynchronization::getDefaultScheduleType ( )

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

46  {
47  return self::SCHEDULE_TYPE_DAILY;
48  }

◆ getDefaultScheduleValue()

ilLDAPCronSynchronization::getDefaultScheduleValue ( )

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

51  {
52  return;
53  }

◆ getDescription()

ilLDAPCronSynchronization::getDescription ( )

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

References $lng.

38  {
39  global $lng;
40 
41  $lng->loadLanguageModule("ldap");
42  return $lng->txt("ldap_user_sync_cron_info");
43  }
global $lng
Definition: privfeed.php:40

◆ getId()

ilLDAPCronSynchronization::getId ( )

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

25  {
26  return "ldap_sync";
27  }

◆ getTitle()

ilLDAPCronSynchronization::getTitle ( )

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

References $lng.

30  {
31  global $lng;
32 
33  $lng->loadLanguageModule('ldap');
34  return $lng->txt('ldap_user_sync_cron');
35  }
global $lng
Definition: privfeed.php:40

◆ hasAutoActivation()

ilLDAPCronSynchronization::hasAutoActivation ( )

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

56  {
57  return false;
58  }

◆ hasFlexibleSchedule()

ilLDAPCronSynchronization::hasFlexibleSchedule ( )

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

61  {
62  return false;
63  }

◆ run()

ilLDAPCronSynchronization::run ( )

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

References $ilLog, $messages, $result, ilLDAPServer\_getCronServerIds(), ilUserCreationContext\CONTEXT_LDAP, deactivateUsers(), ilUserCreationContext\getInstance(), IL_LDAP_BIND_DEFAULT, ilCronJobResult\STATUS_NO_ACTION, and ilCronJobResult\STATUS_OK.

66  {
67  global $ilLog;
68 
70 
71  $messages = array();
72  foreach(ilLDAPServer::_getCronServerIds() as $server_id)
73  {
74  try
75  {
76  $this->current_server = new ilLDAPServer($server_id);
77  $this->current_server->doConnectionCheck();
78  $ilLog->write("LDAP: starting user synchronization for ".$this->current_server->getName());
79 
80  $this->ldap_query = new ilLDAPQuery($this->current_server);
81  $this->ldap_query->bind(IL_LDAP_BIND_DEFAULT);
82 
83  if(is_array($users = $this->ldap_query->fetchUsers()))
84  {
85  // Deactivate ldap users that are not in the list
86  $this->deactivateUsers($this->current_server,$users);
87  }
88 
89  if(count($users))
90  {
91  include_once './Services/User/classes/class.ilUserCreationContext.php';
93 
94  $offset = 0;
95  $limit = 500;
96  while($user_sliced = array_slice($users, $offset, $limit, true))
97  {
98  $ilLog->write("LDAP: Starting update/creation of users ...");
99  $ilLog->write("LDAP: Offset: " . $offset);
100  $this->ldap_to_ilias = new ilLDAPAttributeToUser($this->current_server);
101  $this->ldap_to_ilias->setNewUserAuthMode($this->current_server->getAuthenticationMappingKey());
102  $this->ldap_to_ilias->setUserData($user_sliced);
103  $this->ldap_to_ilias->refresh();
104  $ilLog->write("LDAP: Finished update/creation");
105 
106  $offset += $limit;
107  }
108  $this->counter++;
109  }
110  else
111  {
112  $ilLog->write("LDAP: No users for update/create. Aborting.");
113  }
114  }
115  catch(ilLDAPQueryException $exc)
116  {
117  $mess = $exc->getMessage();
118  $ilLog->write($mess);
119 
120  $messages[] = $mess;
121  }
122  }
123 
124  if($this->counter)
125  {
126  $status = ilCronJobResult::STATUS_OK;
127  }
128  $result = new ilCronJobResult();
129  if(sizeof($messages))
130  {
131  $result->setMessage(implode("\n", $messages));
132  }
133  $result->setStatus($status);
134  return $result;
135  }
$result
static getInstance()
Get instance.
const IL_LDAP_BIND_DEFAULT
deactivateUsers(ilLDAPServer $server, $a_ldap_users)
Deactivate users that are disabled in LDAP.
static _getCronServerIds()
Get list of acticve servers with option 'SyncCron'.
$messages
Definition: en-x-test.php:7
Update/create ILIAS user account by given LDAP attributes according to user attribute mapping setting...
Cron job result data container.
+ Here is the call graph for this function:

Field Documentation

◆ $counter

ilLDAPCronSynchronization::$counter = 0
private

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

◆ $current_server

ilLDAPCronSynchronization::$current_server = null
private

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

◆ $ldap_query

ilLDAPCronSynchronization::$ldap_query = null
private

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

◆ $ldap_to_ilias

ilLDAPCronSynchronization::$ldap_to_ilias = null
private

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


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