Public Member Functions | Private Member Functions | Private Attributes

ilLDAPCronSynchronization Class Reference

Public Member Functions

 __construct ()
 start ()
 Check for LDAP servers and synchronize them.

Private Member Functions

 deactivateUsers ($a_ldap_users)
 Deactivate users that are disabled in LDAP.

Private Attributes

 $current_server = null
 $ldap_query = null
 $log = null

Detailed Description

Author:
Stefan Meyer <smeyer@databay.de>
Version:
$Id$

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


Constructor & Destructor Documentation

ilLDAPCronSynchronization::__construct (  ) 

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

References $ilLog.

        {
                global $ilLog;
                
                $this->log = $ilLog;
        }


Member Function Documentation

ilLDAPCronSynchronization::deactivateUsers ( a_ldap_users  )  [private]

Deactivate users that are disabled in LDAP.

private

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

References ilObjUser::_getExternalAccountsByAuthMode(), and ilObjUser::_toggleActiveStatusOfUsers().

Referenced by start().

        {
                include_once './Services/User/classes/class.ilObjUser.php';
                
                foreach($ext = ilObjUser::_getExternalAccountsByAuthMode('ldap',true) as $usr_id => $external_account)
                {
                        if(!array_key_exists($external_account,$a_ldap_users))
                        {
                                $inactive[] = $usr_id;
                        }
                }
                if(count($inactive))
                {
                        ilObjUser::_toggleActiveStatusOfUsers($inactive,false);
                        $this->log->write('LDAP: Found '.count($inactive).' inactive users.');
                }
                else
                {
                        $this->log->write('LDAP: No inactive users found');
                }
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilLDAPCronSynchronization::start (  ) 

Check for LDAP servers and synchronize them.

public

Parameters:
 

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

References ilLDAPServer::_getCronServerIds(), and deactivateUsers().

        {
                foreach(ilLDAPServer::_getCronServerIds() as $server_id)
                {
                        try
                        {
                                $this->current_server = new ilLDAPServer($server_id);
                                $this->current_server->doConnectionCheck();
                                $this->log->write("LDAP: starting user synchronization for ".$this->current_server->getName());
                                
                                $this->ldap_query = new ilLDAPQuery($this->current_server);
                                $this->ldap_query->bind(IL_LDAP_BIND_DEFAULT);
                                
                                if(is_array($users = $this->ldap_query->fetchUsers()))
                                {
                                        // Deactivate ldap users that are not in the list
                                        $this->deactivateUsers($users);
                                }
                        
                                if(count($users))
                                {       
                                        $this->log->write("LDAP: Starting update/creation of users ...");
                                        $this->ldap_to_ilias = new ilLDAPAttributeToUser($this->current_server);
                                        $this->ldap_to_ilias->setUserData($users);
                                        $this->ldap_to_ilias->refresh();
                                        $this->log->write("LDAP: Finished update/creation");
                                }
                                else
                                {
                                        $this->log->write("LDAP: No users for update/create. Aborting.");
                                }
                        }
                        catch(ilLDAPQueryException $exc)
                        {
                                $this->log->write($exc->getMessage());
                        }
                }
        }

Here is the call graph for this function:


Field Documentation

ilLDAPCronSynchronization::$current_server = null [private]

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

ilLDAPCronSynchronization::$ldap_query = null [private]

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

ilLDAPCronSynchronization::$log = null [private]

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


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