ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
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 157 of file class.ilLDAPCronSynchronization.php.

References $lng, and ilAdministrationSettingsFormHandler\FORM_LDAP.

158  {
159  global $lng;
160 
161  switch($a_form_id)
162  {
164  $a_fields["ldap_user_sync_cron"] = $a_is_active ?
165  $lng->txt("enabled") :
166  $lng->txt("disabled");
167  break;
168  }
169  }
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 131 of file class.ilLDAPCronSynchronization.php.

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

Referenced by run().

132  {
133  global $ilLog;
134 
135  include_once './Services/User/classes/class.ilObjUser.php';
136 
137  foreach($ext = ilObjUser::_getExternalAccountsByAuthMode($server->getAuthenticationMappingKey(),true) as $usr_id => $external_account)
138  {
139  if(!array_key_exists($external_account,$a_ldap_users))
140  {
141  $inactive[] = $usr_id;
142  }
143  }
144  if(count($inactive))
145  {
146  ilObjUser::_toggleActiveStatusOfUsers($inactive,false);
147  $ilLog->write('LDAP: Found '.count($inactive).' inactive users.');
148 
149  $this->counter++;
150  }
151  else
152  {
153  $ilLog->write('LDAP: No inactive users found');
154  }
155  }
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(), deactivateUsers(), 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  $ilLog->write("LDAP: Starting update/creation of users ...");
92  $this->ldap_to_ilias = new ilLDAPAttributeToUser($this->current_server);
93  $this->ldap_to_ilias->setNewUserAuthMode($this->current_server->getAuthenticationMappingKey());
94  #$ilLog->write(print_r($users,true));
95  $this->ldap_to_ilias->setUserData($users);
96  $this->ldap_to_ilias->refresh();
97  $ilLog->write("LDAP: Finished update/creation");
98 
99  $this->counter++;
100  }
101  else
102  {
103  $ilLog->write("LDAP: No users for update/create. Aborting.");
104  }
105  }
106  catch(ilLDAPQueryException $exc)
107  {
108  $mess = $exc->getMessage();
109  $ilLog->write($mess);
110 
111  $messages[] = $mess;
112  }
113  }
114 
115  if($this->counter)
116  {
117  $status = ilCronJobResult::STATUS_OK;
118  }
119  $result = new ilCronJobResult();
120  if(sizeof($messages))
121  {
122  $result->setMessage(implode("\n", $messages));
123  }
124  $result->setStatus($status);
125  return $result;
126  }
$result
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: