ldapsaisie/src/includes/class/class.LSsession.php

3318 lines
102 KiB
PHP
Raw Normal View History

<?php
/*******************************************************************************
* Copyright (C) 2007 Easter-eggs
* https://ldapsaisie.org
*
* Author: See AUTHORS file in top-level directory.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
******************************************************************************/
2020-04-29 15:54:21 +02:00
/**
2021-08-25 18:02:37 +02:00
* Manage user session
*
2021-08-25 18:02:37 +02:00
* This class manage user session
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*/
class LSsession {
2021-08-25 18:02:37 +02:00
/*
* Class constants store and restore from PHP session
*/
2020-04-29 15:54:21 +02:00
/**
* Current LDAP server ID
* @var int|null
*/
private static $ldapServerId = NULL;
2020-04-29 15:54:21 +02:00
/**
* LDAP servers subDns
* @see self::getSubDnLdapServer()
* @var array<string,array>
*/
2021-08-25 18:02:37 +02:00
private static $_subDnLdapServer = array();
/**
* The current topDN
* @var string|null
*/
private static $topDn = NULL;
2020-04-29 15:54:21 +02:00
/**
* The LSldapObject type of current connected user
* @var string|null
*/
2021-08-25 18:02:37 +02:00
private static $LSuserObjectType = NULL;
/**
* Current connected user DN
* @var string|null
*/
private static $dn = NULL;
2020-04-29 15:54:21 +02:00
/**
* Current connected user RDN value (his login)
* @var string|null
*/
private static $rdn = NULL;
2020-04-29 15:54:21 +02:00
/**
* User LDAP credentials
*
* array('dn' => [DN], 'pwd' => [password])
*
* @see self :: startLSsession()
* @see LSauth :: getLDAPcredentials()
* @see LSauthMethod :: getLDAPcredentials()
* @var array<string,string>|false
*/
2021-08-25 18:02:37 +02:00
private static $userLDAPcreds = false;
/**
* Current connected user LSprofiles
*
* array(
* '[LSprofile1]' => array(
* 'topDN1', 'topDN2', [...]
* ),
* [...]
* )
*
* @see self::loadLSprofiles()
* @see self::cacheLSprofiles()
* @see $_SESSION['LSsession']['LSprofiles']
* @var array
*/
private static $LSprofiles = array();
2020-04-29 15:54:21 +02:00
/**
* Current connected user LSaccess (access rights)
*
* array(
* 'topDN1' => array(
* 'SELF' => '[label]',
* '[LSobject type1]' => '[label]',
* '[LSobject type2]' => '[label]',
* [...]
* ),
* )
*
* @see self::loadLSaccess()
* @see $_SESSION['LSsession']['LSaccess']
* @var array
*/
private static $LSaccess = array();
2015-08-21 17:51:52 +02:00
/**
* Current connected user LSaddonsViewsAccess (access on LSaddons views)
*
* array (
* "[addon]::[view ID]" => array (
* 'LSaddon' => [addon name],
* 'id' => [view ID],
* 'label' => [view label],
* 'showInMenu' => [bool],
* ),
* [...]
* )
*
* @see self::loadLSaddonsViewsAccess()
* @see $_SESSION['LSsession']['LSaddonsViewsAccess']
* @var array
*/
private static $LSaddonsViewsAccess = array();
2020-04-29 15:54:21 +02:00
/**
* Temporary files of the session
*
* array (
* '[filepath]' => '[content hash]',
* [...]
* )
*
* @see self::addTmpFile()
* @see $_SESSION['LSsession']['tmp_file']
* @var array
*/
private static $tmp_file = array();
2020-04-29 15:54:21 +02:00
/*
2021-08-25 18:02:37 +02:00
* Class constants not store in session
*/
2020-04-29 15:54:21 +02:00
/**
* Current LDAP server config
* (LSconfig.ldap_servers.<idx>)
* @see self::setLdapServer()
* @var array|null
*/
2021-08-25 18:02:37 +02:00
public static $ldapServer = NULL;
2020-04-29 15:54:21 +02:00
/**
* The template to display
* @see self::setTemplate()
* @var string|null
*/
2021-08-25 18:02:37 +02:00
private static $template = NULL;
/**
* Ajax display telltale
* @see self::setAjaxDisplay()
* @see self::getAjaxDisplay()
* @var bool
*/
private static $ajaxDisplay = false;
/**
* The LSldapObject of connected user
* @see self::getLSuserObject()
* @var LSldapObject|null
*/
private static $LSuserObject = null;
2020-04-29 15:54:21 +02:00
/**
* Initialized session telltale
* @see self::initialize()
* @var bool
*/
private static $initialized = false;
/**
* List of currently loaded LSaddons
* @see self::loadLSaddon()
* @var array<string>
*/
private static $loadedAddons = array();
/**
* Currently registered LSaddons views
*
* array(
* '[addon]' => array (
* '[view ID]' => array (
* 'LSaddon' => '[addon name]',
* 'label' => '[View label]',
* 'function' => '[View function]',
* 'allowedLSprofiles' => array(
* '[LSprofile1]',
* [...]
* ),
* 'showInMenu' => [bool]
* ),
* ),
* )$LSaddon][$viewId]=array (
*
* @see self::registerLSaddonView()
* @var array
*/
2021-08-25 18:02:37 +02:00
private static $LSaddonsViews = array();
/**
* API mode telltale
* @var bool
*/
private static $api_mode = false;
Add API feature Some major changes have been made to handle this new feature : - LSsession now have a flag about API mode. The displayTemplate() and displayAjaxReturn() methods have been adjust to correctly handle this mode. - LSauth system have been adjust to handle a custom API mode : - LSauthMethod can support or not this mode : the $api_mode_supported permit to defined if supported (default, false). Currently, only HTTP (default in API mode) and annonymous mode support it. - An api_access parameter permit to configure witch type of user LSobject types could use the API. This flag must be set to True to allow a type of LSobject (default: False). In a same way, a web_access parameter now permit to disable Web access for some types of users (but this parameter is optional and its default value is True). - The HTTP method is the privileged first method for API mode. In this mode, if auth data aren't present in environment, it will request it by triggered a 403 HTTP error. Realm can be configured with new LSAUTHMETHOD_HTTP_API_REALM constant. - The LStemplate system handle API mode to correctly react on errors: it return a JSON answer instead of HTML page. Error pages also now return adjusted HTTP code (404 or 500). - The LSurl system have been adjust to handle API mode : - On declaring handlers, we could now specify if it's an API view with new $api_mode paremeter of add_handler() method - The LSurlRequest object have a new attribute to check if it's an API request - The error_404() method handle the API mode to return JSON answer. Furthermore, if no handlers matched with the requested URL, API mode is automatically enabled if the requested URL starts with 'api/'. - LSform implement it own API mode flag and a new submited flag that be toggle via the new setSubmited() method. Some major changes also occured on LSformElement classes to specifically handle API input/output for each types of attributes: - a new getApiValue() method permit to retrieve the API value of the attribute (on show API view) - the getPostData() method now have to correctly handle API input for the attribute (on create/modify API views). A programmatic way have been adopted for each types of attributes. - The LSimport and LScli create/modify commands also evolved to enable API mode of the LSform. This permit to take advantage of the new capability of LSform/LSformElement to handle input values with a programmatic way. - New routes have been add to handle API views. All this new routes start with 'api/1.0/' and use the same URL schema as the web UI. The API currently permit to search/show/add/modify/remove LSobjects and manages their relations.
2021-02-03 14:40:28 +01:00
/**
* Get session info by key
*
* @param string $key The info
*
* @return mixed The info or null
*/
public static function get($key) {
switch($key) {
case 'top_dn':
return self :: getTopDn();
case 'root_dn':
return self :: getRootDn();
case 'sub_dn_name':
return self :: getSubDnName();
case 'sub_dn_label':
return self :: getSubDnLabel();
case 'authenticated_user_dn':
return self :: $dn;
case 'authenticated_user_type':
return self :: $LSuserObjectType;
case 'authenticated_user':
return self :: getLSuserObject();
case 'is_connected':
return self :: isConnected();
case 'global_search_enabled':
return self :: globalSearch();
case 'email_sender':
return self :: getEmailSender();
Add API feature Some major changes have been made to handle this new feature : - LSsession now have a flag about API mode. The displayTemplate() and displayAjaxReturn() methods have been adjust to correctly handle this mode. - LSauth system have been adjust to handle a custom API mode : - LSauthMethod can support or not this mode : the $api_mode_supported permit to defined if supported (default, false). Currently, only HTTP (default in API mode) and annonymous mode support it. - An api_access parameter permit to configure witch type of user LSobject types could use the API. This flag must be set to True to allow a type of LSobject (default: False). In a same way, a web_access parameter now permit to disable Web access for some types of users (but this parameter is optional and its default value is True). - The HTTP method is the privileged first method for API mode. In this mode, if auth data aren't present in environment, it will request it by triggered a 403 HTTP error. Realm can be configured with new LSAUTHMETHOD_HTTP_API_REALM constant. - The LStemplate system handle API mode to correctly react on errors: it return a JSON answer instead of HTML page. Error pages also now return adjusted HTTP code (404 or 500). - The LSurl system have been adjust to handle API mode : - On declaring handlers, we could now specify if it's an API view with new $api_mode paremeter of add_handler() method - The LSurlRequest object have a new attribute to check if it's an API request - The error_404() method handle the API mode to return JSON answer. Furthermore, if no handlers matched with the requested URL, API mode is automatically enabled if the requested URL starts with 'api/'. - LSform implement it own API mode flag and a new submited flag that be toggle via the new setSubmited() method. Some major changes also occured on LSformElement classes to specifically handle API input/output for each types of attributes: - a new getApiValue() method permit to retrieve the API value of the attribute (on show API view) - the getPostData() method now have to correctly handle API input for the attribute (on create/modify API views). A programmatic way have been adopted for each types of attributes. - The LSimport and LScli create/modify commands also evolved to enable API mode of the LSform. This permit to take advantage of the new capability of LSform/LSformElement to handle input values with a programmatic way. - New routes have been add to handle API views. All this new routes start with 'api/1.0/' and use the same URL schema as the web UI. The API currently permit to search/show/add/modify/remove LSobjects and manages their relations.
2021-02-03 14:40:28 +01:00
case 'api_mode':
return boolval(self :: $api_mode);
case 'ldap_server_id':
2023-01-09 19:32:06 +01:00
return intval(self :: $ldapServerId);
case 'LSprofiles':
return self :: $LSprofiles;
}
return null;
}
- Deplacement du require de functions.php dans le fichier de classe de LSsession pour ne pas obliger sa recopie. - LSlog : Début d'ecriture d'une possibilité de fichiers de logs - Ajout d'une fonction de test validPas() retournant false - LSformElement : Ajout d'un type de LSformElement gérant les attributs maildir. Il fonctionne en frontend du LSaddon Maildir. - LSsession : -> Ajout de la méthode statique includeFile() utilisé à la place de la fonction php include_once() -> displayAjaxReturn() : Gestion du LSredirect -> Ajout d'un require_once() sur functions.php - LSaddon::FTP : Ajout de la fonction renameDirByFTP() - LSaddon::Maildir : -> Ajout de la fonction renameMaildirByFTP() -> Modification des fonctions createMaildirByFTP() et removeMaildirByFTP() pour pour pouvoir leur passé en deuxième paramètre le chemin de la maildir à utlisé - LSdefault : -> LSdebugHidde() devient hideLSdebug() -> Ajout de la méthode hideLSerror() accroché sur l'événement double-clique de la LSerrorsBox -> displayErrorBox() : plus de timeout d'affichage des erreurs -> checkAjaxReturn() : Gestion des LSredirect - LSform : -> plus de LSformRedirect : utilisation de LSdefault::LSredirect - modify.php et create.php : Utilisation des LSdefault::LSredirect et affichages des erreurs non-bloquant sur la page suivante. - LSerror : -> Utilisation d'une variable de session pour stocké les erreurs -> Ajout de la méthode resetError() exécutée à chaque exécution de LSerror::getErrors() - LSldapObject : -> Correction de la gestion des binding -> Event before_modify : bloquant en cas d'échec -> Event after_modify : non-bloquant en cas d'échec
2009-01-21 18:08:09 +01:00
/**
* Include PHP file
- Deplacement du require de functions.php dans le fichier de classe de LSsession pour ne pas obliger sa recopie. - LSlog : Début d'ecriture d'une possibilité de fichiers de logs - Ajout d'une fonction de test validPas() retournant false - LSformElement : Ajout d'un type de LSformElement gérant les attributs maildir. Il fonctionne en frontend du LSaddon Maildir. - LSsession : -> Ajout de la méthode statique includeFile() utilisé à la place de la fonction php include_once() -> displayAjaxReturn() : Gestion du LSredirect -> Ajout d'un require_once() sur functions.php - LSaddon::FTP : Ajout de la fonction renameDirByFTP() - LSaddon::Maildir : -> Ajout de la fonction renameMaildirByFTP() -> Modification des fonctions createMaildirByFTP() et removeMaildirByFTP() pour pour pouvoir leur passé en deuxième paramètre le chemin de la maildir à utlisé - LSdefault : -> LSdebugHidde() devient hideLSdebug() -> Ajout de la méthode hideLSerror() accroché sur l'événement double-clique de la LSerrorsBox -> displayErrorBox() : plus de timeout d'affichage des erreurs -> checkAjaxReturn() : Gestion des LSredirect - LSform : -> plus de LSformRedirect : utilisation de LSdefault::LSredirect - modify.php et create.php : Utilisation des LSdefault::LSredirect et affichages des erreurs non-bloquant sur la page suivante. - LSerror : -> Utilisation d'une variable de session pour stocké les erreurs -> Ajout de la méthode resetError() exécutée à chaque exécution de LSerror::getErrors() - LSldapObject : -> Correction de la gestion des binding -> Event before_modify : bloquant en cas d'échec -> Event after_modify : non-bloquant en cas d'échec
2009-01-21 18:08:09 +01:00
*
* @param string $file The path to the file to include :
* - if $external == false : the path must be relative to LS_ROOT_DIR
* - if $external == true : the path could be absolute or relative. If
* relative, it will be treated with PHP include path.
* @param boolean $external If true, file consided as external (optional, default: false)
* @param boolean $warn If true, a warning will be log if file not found (optional, default: true)
* This warning will be emit using LSlog if it's already loaded or error_log()
* otherwise.
- Deplacement du require de functions.php dans le fichier de classe de LSsession pour ne pas obliger sa recopie. - LSlog : Début d'ecriture d'une possibilité de fichiers de logs - Ajout d'une fonction de test validPas() retournant false - LSformElement : Ajout d'un type de LSformElement gérant les attributs maildir. Il fonctionne en frontend du LSaddon Maildir. - LSsession : -> Ajout de la méthode statique includeFile() utilisé à la place de la fonction php include_once() -> displayAjaxReturn() : Gestion du LSredirect -> Ajout d'un require_once() sur functions.php - LSaddon::FTP : Ajout de la fonction renameDirByFTP() - LSaddon::Maildir : -> Ajout de la fonction renameMaildirByFTP() -> Modification des fonctions createMaildirByFTP() et removeMaildirByFTP() pour pour pouvoir leur passé en deuxième paramètre le chemin de la maildir à utlisé - LSdefault : -> LSdebugHidde() devient hideLSdebug() -> Ajout de la méthode hideLSerror() accroché sur l'événement double-clique de la LSerrorsBox -> displayErrorBox() : plus de timeout d'affichage des erreurs -> checkAjaxReturn() : Gestion des LSredirect - LSform : -> plus de LSformRedirect : utilisation de LSdefault::LSredirect - modify.php et create.php : Utilisation des LSdefault::LSredirect et affichages des erreurs non-bloquant sur la page suivante. - LSerror : -> Utilisation d'une variable de session pour stocké les erreurs -> Ajout de la méthode resetError() exécutée à chaque exécution de LSerror::getErrors() - LSldapObject : -> Correction de la gestion des binding -> Event before_modify : bloquant en cas d'échec -> Event after_modify : non-bloquant en cas d'échec
2009-01-21 18:08:09 +01:00
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @return boolean True if file is loaded, false otherwise
- Deplacement du require de functions.php dans le fichier de classe de LSsession pour ne pas obliger sa recopie. - LSlog : Début d'ecriture d'une possibilité de fichiers de logs - Ajout d'une fonction de test validPas() retournant false - LSformElement : Ajout d'un type de LSformElement gérant les attributs maildir. Il fonctionne en frontend du LSaddon Maildir. - LSsession : -> Ajout de la méthode statique includeFile() utilisé à la place de la fonction php include_once() -> displayAjaxReturn() : Gestion du LSredirect -> Ajout d'un require_once() sur functions.php - LSaddon::FTP : Ajout de la fonction renameDirByFTP() - LSaddon::Maildir : -> Ajout de la fonction renameMaildirByFTP() -> Modification des fonctions createMaildirByFTP() et removeMaildirByFTP() pour pour pouvoir leur passé en deuxième paramètre le chemin de la maildir à utlisé - LSdefault : -> LSdebugHidde() devient hideLSdebug() -> Ajout de la méthode hideLSerror() accroché sur l'événement double-clique de la LSerrorsBox -> displayErrorBox() : plus de timeout d'affichage des erreurs -> checkAjaxReturn() : Gestion des LSredirect - LSform : -> plus de LSformRedirect : utilisation de LSdefault::LSredirect - modify.php et create.php : Utilisation des LSdefault::LSredirect et affichages des erreurs non-bloquant sur la page suivante. - LSerror : -> Utilisation d'une variable de session pour stocké les erreurs -> Ajout de la méthode resetError() exécutée à chaque exécution de LSerror::getErrors() - LSldapObject : -> Correction de la gestion des binding -> Event before_modify : bloquant en cas d'échec -> Event after_modify : non-bloquant en cas d'échec
2009-01-21 18:08:09 +01:00
*/
public static function includeFile($file, $external=false, $warn=true) {
2020-04-29 15:15:41 +02:00
$path = ($external?'':LS_ROOT_DIR."/").$file;
$local_path = ($external?'':LS_ROOT_DIR."/").LS_LOCAL_DIR.$file;
2020-04-29 15:15:41 +02:00
$path = (file_exists($local_path)?$local_path:$path);
if (!isAbsolutePath($path)) {
$found = stream_resolve_include_path($path);
if ($found === false) {
self :: log(
($warn?'WARNING':'TRACE'),
"includeFile($file, external=$external) : file $path not found in include path."
);
return false;
}
else {
self :: log_trace("includeFile($file, external=$external): file path found using include path => '$found'");
$path = $found;
}
}
else if (!file_exists($path)) {
self :: log(
($warn?'WARNING':'TRACE'),
"includeFile($file, external=$external): file not found ($local_path / $path)"
);
return false;
}
if (!include_once($path)) {
// Always log as warning in this case
self :: log_warning("includeFile($file, external=$external): include_once($path) not returned TRUE");
return false;
- Deplacement du require de functions.php dans le fichier de classe de LSsession pour ne pas obliger sa recopie. - LSlog : Début d'ecriture d'une possibilité de fichiers de logs - Ajout d'une fonction de test validPas() retournant false - LSformElement : Ajout d'un type de LSformElement gérant les attributs maildir. Il fonctionne en frontend du LSaddon Maildir. - LSsession : -> Ajout de la méthode statique includeFile() utilisé à la place de la fonction php include_once() -> displayAjaxReturn() : Gestion du LSredirect -> Ajout d'un require_once() sur functions.php - LSaddon::FTP : Ajout de la fonction renameDirByFTP() - LSaddon::Maildir : -> Ajout de la fonction renameMaildirByFTP() -> Modification des fonctions createMaildirByFTP() et removeMaildirByFTP() pour pour pouvoir leur passé en deuxième paramètre le chemin de la maildir à utlisé - LSdefault : -> LSdebugHidde() devient hideLSdebug() -> Ajout de la méthode hideLSerror() accroché sur l'événement double-clique de la LSerrorsBox -> displayErrorBox() : plus de timeout d'affichage des erreurs -> checkAjaxReturn() : Gestion des LSredirect - LSform : -> plus de LSformRedirect : utilisation de LSdefault::LSredirect - modify.php et create.php : Utilisation des LSdefault::LSredirect et affichages des erreurs non-bloquant sur la page suivante. - LSerror : -> Utilisation d'une variable de session pour stocké les erreurs -> Ajout de la méthode resetError() exécutée à chaque exécution de LSerror::getErrors() - LSldapObject : -> Correction de la gestion des binding -> Event before_modify : bloquant en cas d'échec -> Event after_modify : non-bloquant en cas d'échec
2009-01-21 18:08:09 +01:00
}
return true;
- Deplacement du require de functions.php dans le fichier de classe de LSsession pour ne pas obliger sa recopie. - LSlog : Début d'ecriture d'une possibilité de fichiers de logs - Ajout d'une fonction de test validPas() retournant false - LSformElement : Ajout d'un type de LSformElement gérant les attributs maildir. Il fonctionne en frontend du LSaddon Maildir. - LSsession : -> Ajout de la méthode statique includeFile() utilisé à la place de la fonction php include_once() -> displayAjaxReturn() : Gestion du LSredirect -> Ajout d'un require_once() sur functions.php - LSaddon::FTP : Ajout de la fonction renameDirByFTP() - LSaddon::Maildir : -> Ajout de la fonction renameMaildirByFTP() -> Modification des fonctions createMaildirByFTP() et removeMaildirByFTP() pour pour pouvoir leur passé en deuxième paramètre le chemin de la maildir à utlisé - LSdefault : -> LSdebugHidde() devient hideLSdebug() -> Ajout de la méthode hideLSerror() accroché sur l'événement double-clique de la LSerrorsBox -> displayErrorBox() : plus de timeout d'affichage des erreurs -> checkAjaxReturn() : Gestion des LSredirect - LSform : -> plus de LSformRedirect : utilisation de LSdefault::LSredirect - modify.php et create.php : Utilisation des LSdefault::LSredirect et affichages des erreurs non-bloquant sur la page suivante. - LSerror : -> Utilisation d'une variable de session pour stocké les erreurs -> Ajout de la méthode resetError() exécutée à chaque exécution de LSerror::getErrors() - LSldapObject : -> Correction de la gestion des binding -> Event before_modify : bloquant en cas d'échec -> Event after_modify : non-bloquant en cas d'échec
2009-01-21 18:08:09 +01:00
}
/**
* Lancement de LSconfig
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @return bool true si tout c'est bien passé, false sinon
*/
private static function startLSconfig() {
if (self :: loadLSclass('LSconfig')) {
if (LSconfig :: start()) {
return true;
}
}
die("ERROR : Can't load configuration files.");
return;
}
2019-06-28 18:00:37 +02:00
/**
* Lancement de LSlog
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @return bool true si tout c'est bien passé, false sinon
2019-06-28 18:00:37 +02:00
*/
private static function startLSlog() {
if (self :: loadLSclass('LSlog')) {
if (LSlog :: start()) {
return true;
}
}
return False;
}
2020-05-08 15:51:21 +02:00
/*
* Log a message via class logger (of other method if LSlog is not loaded)
*
* @param string $key The log level (see LSlog)
* @param string $message The message to log
2020-05-08 15:51:21 +02:00
*
* @return void
2020-05-08 15:51:21 +02:00
**/
protected static function log($level, $message) {
if (class_exists('LSlog')) {
LSlog :: get_logger(get_called_class()) -> logging($level, $message);
return;
}
// Alternative logging if LSlog is not already started
$formated_message = "LSsession - $level - $message";
switch ($level) {
case 'FATAL':
case 'ERROR':
error_log($formated_message);
if ($level == 'FATAL')
die($formated_message);
break;
default:
LSdebug($formated_message);
}
}
2020-08-07 18:17:02 +02:00
/**
2021-06-10 18:45:00 +02:00
* Log an exception via class logger
*
* @param Exception $exception The exception to log
* @param string|null $prefix Custom message prefix (optional, see self :: log_exception())
* @param boolean $fatal Log exception as a fatal error (optional, default: true)
2021-06-10 18:45:00 +02:00
*
* @return void
2021-06-10 18:45:00 +02:00
**/
protected static function log_exception($exception, $prefix=null, $fatal=true) {
2020-08-07 18:17:02 +02:00
if (class_exists('LSlog')) {
LSlog :: get_logger(get_called_class()) -> exception($exception, $prefix, $fatal);
return;
}
// Implement basic exception message formating
$message = ($prefix?"$prefix :\n":"An exception occured :\n").
"## ".$exception->getFile().":".$exception->getLine(). " : ". $exception->getMessage();
self :: log(($fatal?'FATAL':'ERROR'), $message);
}
2020-08-07 18:05:50 +02:00
/**
* Log a message with level TRACE
*
* @param string $message The message to log
2020-08-07 18:05:50 +02:00
*
* @return void
2020-08-07 18:05:50 +02:00
**/
protected static function log_trace($message) {
self :: log('TRACE', $message);
}
2020-05-08 15:51:21 +02:00
/**
* Log a message with level DEBUG
*
* @param string $message The message to log
2020-05-08 15:51:21 +02:00
*
* @return void
2020-05-08 15:51:21 +02:00
**/
protected static function log_debug($message) {
self :: log('DEBUG', $message);
}
/**
* Log a message with level INFO
*
* @param string $message The message to log
2020-05-08 15:51:21 +02:00
*
* @return void
2020-05-08 15:51:21 +02:00
**/
protected static function log_info($message) {
self :: log('INFO', $message);
}
/**
* Log a message with level WARNING
*
* @param string $message The message to log
2020-05-08 15:51:21 +02:00
*
* @return void
2020-05-08 15:51:21 +02:00
**/
protected static function log_warning($message) {
self :: log('WARNING', $message);
}
/**
* Log a message with level ERROR
*
* @param string $message The message to log
2020-05-08 15:51:21 +02:00
*
* @return void
2020-05-08 15:51:21 +02:00
**/
protected static function log_error($message) {
self :: log('ERROR', $message);
}
/**
* Log a message with level FATAL
*
* @param string $message The message to log
2020-05-08 15:51:21 +02:00
*
* @return void
2020-05-08 15:51:21 +02:00
**/
protected static function log_fatal($message) {
self :: log('FATAL', $message);
}
/**
2021-08-25 18:02:37 +02:00
* Start LSurl
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @return bool true on success, false otherwise
*/
private static function startLSurl() {
if (self :: loadLSclass('LSurl') && self :: includeFile(LS_INCLUDE_DIR . "routes.php")) {
return true;
}
return False;
}
/**
2021-08-25 18:02:37 +02:00
* Start and initialize LStemplate
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @return bool true on success, false otherwise
2020-04-29 15:15:41 +02:00
*/
private static function startLStemplate() {
if ( self :: loadLSclass('LStemplate') ) {
if (!LStemplate :: start(
array(
2020-04-29 15:15:41 +02:00
'smarty_path' => LSconfig :: get('Smarty'),
'template_dir' => LS_ROOT_DIR . '/'. LS_TEMPLATES_DIR,
'image_dir' => LS_ROOT_DIR. '/'. LS_IMAGES_DIR,
'css_dir' => LS_ROOT_DIR. '/'. LS_CSS_DIR,
'js_dir' => LS_ROOT_DIR. '/'. LS_JS_DIR,
'libs_dir' => LS_ROOT_DIR. '/'. LS_LIB_DIR,
2020-04-29 15:15:41 +02:00
'compile_dir' => LS_TMP_DIR_PATH,
'debug' => LSdebug,
'debug_smarty' => isset($_REQUEST['LStemplate_debug']),
)
))
return False;
return True;
}
return False;
}
2020-04-29 15:15:41 +02:00
/**
2021-08-25 18:02:37 +02:00
* Retrieve current topDn (=DN scope browsed)
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @return string The current topDn
*/
public static function getTopDn() {
- LSsearch/LSsearchEntry : Added a new classes to doing and exploit ldap object search -> view/select => change to use it (php+template+js) -> LSattr_html_select_object/LSattr_html_select_list => change to use it -> LSldapObject : -> change listObjectsName() / searchObject() / getSelectArray() / listObjects() -> comment search() function -> Add triggers to clean cache -> LSpeople : Update search config -> LSsession : Change function to use it : - getSubDnLdapServer() - loadLSprofiles() - LSrelation : Deplace error codes declaration from LSsession in class file - LSldapObject : -> change getObjectFilter() / getLabel() / getSubDnValue() / getSubDnName() for can call then staticaly -> Add afterModify() function and trigger -> Change getObjectFilter() / listObjectsInRelation() to use Net_LDAP2_Filter -> Add __get() function -> Move one LSerror code for LSrelation function from LSsession class file -> Add a global variable to save cached data ($cache) -> Change subDn and subDnName access methods - LSauth : Move LSsession auth procedure in a dedicated class -> LSsession : Change startLSsession() to use it - LSsession : -> Add getRootDn() function -> Fix getTopDn() to return root DN if no topDn is currently defined -> Create dedicated functions to support recoveryPassword mecanism : - recoverPasswd() - recoverPasswdSendMail() - recoverPasswdFirstStep() - recoverPasswdSecondStep -> Customize LSdebug return and display (php+js) -> Clean unused error codes -> Move LSrelation error codes -> Comment ajax method
2009-10-30 01:03:17 +01:00
if (!is_null(self :: $topDn)) {
return self :: $topDn;
}
else {
return self :: getRootDn();
}
}
2020-04-29 15:54:21 +02:00
- LSsearch/LSsearchEntry : Added a new classes to doing and exploit ldap object search -> view/select => change to use it (php+template+js) -> LSattr_html_select_object/LSattr_html_select_list => change to use it -> LSldapObject : -> change listObjectsName() / searchObject() / getSelectArray() / listObjects() -> comment search() function -> Add triggers to clean cache -> LSpeople : Update search config -> LSsession : Change function to use it : - getSubDnLdapServer() - loadLSprofiles() - LSrelation : Deplace error codes declaration from LSsession in class file - LSldapObject : -> change getObjectFilter() / getLabel() / getSubDnValue() / getSubDnName() for can call then staticaly -> Add afterModify() function and trigger -> Change getObjectFilter() / listObjectsInRelation() to use Net_LDAP2_Filter -> Add __get() function -> Move one LSerror code for LSrelation function from LSsession class file -> Add a global variable to save cached data ($cache) -> Change subDn and subDnName access methods - LSauth : Move LSsession auth procedure in a dedicated class -> LSsession : Change startLSsession() to use it - LSsession : -> Add getRootDn() function -> Fix getTopDn() to return root DN if no topDn is currently defined -> Create dedicated functions to support recoveryPassword mecanism : - recoverPasswd() - recoverPasswdSendMail() - recoverPasswdFirstStep() - recoverPasswdSecondStep -> Customize LSdebug return and display (php+js) -> Clean unused error codes -> Move LSrelation error codes -> Comment ajax method
2009-10-30 01:03:17 +01:00
/**
2021-08-25 18:02:37 +02:00
* Retrieve current rootDn (=LDAP server root base DN)
- LSsearch/LSsearchEntry : Added a new classes to doing and exploit ldap object search -> view/select => change to use it (php+template+js) -> LSattr_html_select_object/LSattr_html_select_list => change to use it -> LSldapObject : -> change listObjectsName() / searchObject() / getSelectArray() / listObjects() -> comment search() function -> Add triggers to clean cache -> LSpeople : Update search config -> LSsession : Change function to use it : - getSubDnLdapServer() - loadLSprofiles() - LSrelation : Deplace error codes declaration from LSsession in class file - LSldapObject : -> change getObjectFilter() / getLabel() / getSubDnValue() / getSubDnName() for can call then staticaly -> Add afterModify() function and trigger -> Change getObjectFilter() / listObjectsInRelation() to use Net_LDAP2_Filter -> Add __get() function -> Move one LSerror code for LSrelation function from LSsession class file -> Add a global variable to save cached data ($cache) -> Change subDn and subDnName access methods - LSauth : Move LSsession auth procedure in a dedicated class -> LSsession : Change startLSsession() to use it - LSsession : -> Add getRootDn() function -> Fix getTopDn() to return root DN if no topDn is currently defined -> Create dedicated functions to support recoveryPassword mecanism : - recoverPasswd() - recoverPasswdSendMail() - recoverPasswdFirstStep() - recoverPasswdSecondStep -> Customize LSdebug return and display (php+js) -> Clean unused error codes -> Move LSrelation error codes -> Comment ajax method
2009-10-30 01:03:17 +01:00
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @return string The current rootDn
- LSsearch/LSsearchEntry : Added a new classes to doing and exploit ldap object search -> view/select => change to use it (php+template+js) -> LSattr_html_select_object/LSattr_html_select_list => change to use it -> LSldapObject : -> change listObjectsName() / searchObject() / getSelectArray() / listObjects() -> comment search() function -> Add triggers to clean cache -> LSpeople : Update search config -> LSsession : Change function to use it : - getSubDnLdapServer() - loadLSprofiles() - LSrelation : Deplace error codes declaration from LSsession in class file - LSldapObject : -> change getObjectFilter() / getLabel() / getSubDnValue() / getSubDnName() for can call then staticaly -> Add afterModify() function and trigger -> Change getObjectFilter() / listObjectsInRelation() to use Net_LDAP2_Filter -> Add __get() function -> Move one LSerror code for LSrelation function from LSsession class file -> Add a global variable to save cached data ($cache) -> Change subDn and subDnName access methods - LSauth : Move LSsession auth procedure in a dedicated class -> LSsession : Change startLSsession() to use it - LSsession : -> Add getRootDn() function -> Fix getTopDn() to return root DN if no topDn is currently defined -> Create dedicated functions to support recoveryPassword mecanism : - recoverPasswd() - recoverPasswdSendMail() - recoverPasswdFirstStep() - recoverPasswdSecondStep -> Customize LSdebug return and display (php+js) -> Clean unused error codes -> Move LSrelation error codes -> Comment ajax method
2009-10-30 01:03:17 +01:00
*/
public static function getRootDn() {
return self :: $ldapServer['ldap_config']['basedn'];
}
/**
2021-08-25 18:02:37 +02:00
* Start LSerror
*
* @author Benjamin Renard <brenard@easter-eggs.com
*
* @return bool True on success, false otherwise
*/
private static function startLSerror() {
if(!self :: loadLSclass('LSerror')) {
return false;
- LdapSaisie : J'ai commencé à écrire la docummentation de LdapSaisie que j'espère pour voir bientôt ajouté au SVN. Cela me fait mettre le doit sur quelques problèmes de nommages, d'organisation que j'ai corrigé sur le fait : - Concepte de level était enfaite celui de subDn : seule le nom subDn doit rester. - Le concept de LSrights dans LSsession et config.inc.php était mal nommé. Il correspond plus à la définition de LSprofile en réalité. Je l'ai renommé ainsi. - Les paramètres authobject et authobject_pwdattr n'étaient pas très représentatif. Je les ai renommé en authObjectType et authObjectTypeAttrPwd. - Templates : -> Correction du template default dans le but de changer la couleur bleu dominante juger trop flashy :). Au passage j'ai dégagé l'image de fond de #main utilisé pour colorer le menu : cette méthode est moche et quitte a à faire du moche je préfère utiliser un vulgaire tableau que des bidouille de ce genre. -> Création d'un logo pour LdapSaisie qui vient remplacer le logo Easter-Eggs utilisé jusqu'alors. -> Ajout d'un favicon. - LSerror : -> J'ai déplacé les definitions de code d'erreur dans le contexte concerné (càd dans les fichiers de définition des classes) (Feature Request #1757) -> J'en ai profité pour renommer les codes d'erreur avec un prefixe pour eviter les doublons -> J'ai donc modifié une grande partie des fichiers pour changer les codes erreurs utilisés -> Ajout d'une méthode getError() utilisé par getErrors() -> Modification de la méthode stop() - LSformElement_password : - Correction d'un bug dans la génération des mots de passe dans un formulaire de création d'objet. - Ajout d'une possiblité de choisir le type de hashage du mot de passe stocké dans l'annuaire (Feature Request #1756) - Traduction des commentaires - LSattribute : Ajout des vérifications dans les méthodes de la classe lors de l'utilisation des objets html et ldap. - LSsession : -> Renforcement des méthodes faisant des inclusions d'autres fichiers php.
2009-01-02 17:00:25 +01:00
}
self :: defineLSerrors();
return true;
}
/**
* Load an LdapSaisie class
*
* @param string $class The class name to load (Example : LSpeople)
* @param string|null $type (Optionnel) The class type to load (Example : LSobjects)
* @param bool $warn (Optionnel) Trigger LSsession_05 error if an error occured loading this class (Default: false)
*
* @author Benjamin Renard <brenard@easter-eggs.com
2020-04-29 15:54:21 +02:00
*
* @return boolean true on success, otherwise false
*/
public static function loadLSclass($class, $type=null, $warn=false) {
if (class_exists($class))
return true;
if($type)
$class = "$type.$class";
if (self :: includeFile(LS_CLASS_DIR .'class.'.$class.'.php', false, $warn))
return true;
if ($warn)
LSerror :: addErrorCode('LSsession_05', $class);
return False;
}
/**
* Load LSobject type
*
* @param string $object Name of the LSobject type
* @param boolean $warn Set to false to avoid warning in case of loading error (optional, default: true)
*
* @return boolean True if LSobject type loaded, false otherwise
*/
public static function loadLSobject($object, $warn=true) {
if(class_exists($object)) {
return true;
}
$error = false;
// Load LSldapObject class
if (!self :: loadLSclass('LSldapObject')) {
self :: log_error("loadLSobject($object): fail to load LSldapObject class");
$error = true;
}
// Check LSobject type name
elseif (!LSldapObject :: isValidTypeName($object)) {
self :: log_error("loadLSobject($object): invalid LSobject type name");
$error = true;
}
// Load config file
elseif (!self :: includeFile( LS_OBJECTS_DIR . 'config.LSobjects.'.$object.'.php' ) || !isset($GLOBALS['LSobjects'][$object])) {
2020-05-08 15:51:21 +02:00
self :: log_error("loadLSobject($object): Fail to include 'config.LSobjects.$object.php' file");
$error = true;
- LdapSaisie : J'ai commencé à écrire la docummentation de LdapSaisie que j'espère pour voir bientôt ajouté au SVN. Cela me fait mettre le doit sur quelques problèmes de nommages, d'organisation que j'ai corrigé sur le fait : - Concepte de level était enfaite celui de subDn : seule le nom subDn doit rester. - Le concept de LSrights dans LSsession et config.inc.php était mal nommé. Il correspond plus à la définition de LSprofile en réalité. Je l'ai renommé ainsi. - Les paramètres authobject et authobject_pwdattr n'étaient pas très représentatif. Je les ai renommé en authObjectType et authObjectTypeAttrPwd. - Templates : -> Correction du template default dans le but de changer la couleur bleu dominante juger trop flashy :). Au passage j'ai dégagé l'image de fond de #main utilisé pour colorer le menu : cette méthode est moche et quitte a à faire du moche je préfère utiliser un vulgaire tableau que des bidouille de ce genre. -> Création d'un logo pour LdapSaisie qui vient remplacer le logo Easter-Eggs utilisé jusqu'alors. -> Ajout d'un favicon. - LSerror : -> J'ai déplacé les definitions de code d'erreur dans le contexte concerné (càd dans les fichiers de définition des classes) (Feature Request #1757) -> J'en ai profité pour renommer les codes d'erreur avec un prefixe pour eviter les doublons -> J'ai donc modifié une grande partie des fichiers pour changer les codes erreurs utilisés -> Ajout d'une méthode getError() utilisé par getErrors() -> Modification de la méthode stop() - LSformElement_password : - Correction d'un bug dans la génération des mots de passe dans un formulaire de création d'objet. - Ajout d'une possiblité de choisir le type de hashage du mot de passe stocké dans l'annuaire (Feature Request #1756) - Traduction des commentaires - LSattribute : Ajout des vérifications dans les méthodes de la classe lors de l'utilisation des objets html et ldap. - LSsession : -> Renforcement des méthodes faisant des inclusions d'autres fichiers php.
2009-01-02 17:00:25 +01:00
}
// Check config file
elseif (!isset($GLOBALS['LSobjects'][$object]) || !is_array($GLOBALS['LSobjects'][$object])) {
self :: log_error("loadLSobject($object): \$GLOBALS['LSobjects'][$object] is not declared after loaded config file (or is not an array).");
$error = true;
}
// Set LSobject type configuration
elseif (!LSconfig :: set("LSobjects.$object", $GLOBALS['LSobjects'][$object])) {
self :: log_error("loadLSobject($object): Fail to LSconfig :: set('LSobjects.$object', \$GLOBALS['LSobjects'][$object])");
$error = true;
}
// Load LSaddons used by this LSobject type (if configured)
else if (isset($GLOBALS['LSobjects'][$object]['LSaddons'])) {
if (!is_array($GLOBALS['LSobjects'][$object]['LSaddons']))
$GLOBALS['LSobjects'][$object]['LSaddons'] = array($GLOBALS['LSobjects'][$object]['LSaddons']);
foreach ($GLOBALS['LSobjects'][$object]['LSaddons'] as $addon) {
if (!self :: loadLSaddon($addon)) {
self :: log_error("loadLSobject($object): Fail to load LSaddon '$addon'");
$error = true;
2020-04-29 15:54:21 +02:00
}
}
}
// Load or declare corresponding PHP class (if no previous error occured)
if (!$error && !self :: loadLSclass($object, 'LSobjects')) {
self :: log_debug("loadLSobject($object): Fail to load $object class. Implement simple one.");
eval("class $object extends LSldapObject {};");
}
// Warn on error (is enabled)
if ($error && $warn)
LSerror :: addErrorCode('LSsession_04', $object);
return !$error;
}
/**
* Load a LSaddon (if not already loaded)
*
* @param string $addon The addon name (ex: samba)
*
* @author Benjamin Renard <brenard@easter-eggs.com
2020-04-29 15:54:21 +02:00
*
* @return boolean True if addon loaded, false otherwise
*/
public static function loadLSaddon($addon) {
if (in_array($addon, self :: $loadedAddons))
return true;
if(self :: includeFile(LS_ADDONS_DIR .'LSaddons.'.$addon.'.php')) {
// Load LSaddon config file (without warning if not found)
$conf_file = LS_CONF_DIR."LSaddons/config.LSaddons.".$addon.".php";
if (self :: includeFile($conf_file, false, false))
2020-05-08 15:51:21 +02:00
self :: log_debug("loadLSaddon($addon): config file '$conf_file' loaded.");
else
2020-05-08 15:51:21 +02:00
self :: log_debug("loadLSaddon($addon): config file '$conf_file' not found.");
- LSview : ajout de input hidden pour contenir les informations du type et du DN de l'objet affiché. - LSmail : Ajout d'une fonctionalité d'envoie de mail depuis l'interface. -> Modification de LSformElement_mail pour utiliser cette fonctionalité -> Agrémentation du fichier index_ajax.php -> Ajout d'un LSaddons :: mail - LSsession : -> Ajout d'une méthode getEmailSender() -> Utilisation de la méthode getEmailSender() pour la partie de récupération de mot de passe -> Revue des méthodes loadLSaddon() et loadLSaddons() - LSconfirmBox : -> Ajout de binding onClose() et onCancel() - LSsmoothbox : -> Déport de la creation de la structure dans la méthode build() -> Suppression du principe de refreshElement au profit de binding sur les évenements onClose, onValid et onCancel -> Ajout des méthodes addEvent() et fireEvent() -> Suppression de la méthode setRefreshElement() -> Ajout de la méthode asNew() pour remettre l'objet dans son état d'origine pour l'utilisation simultané de l'objet par plusieurs autres -> Vérification lors du clique sur le closeBtn qu'une précédente confirmBox n'est pas déjà ouvert -> La méthode close() ne fait plus que fermer la LSsmoothbox et les méthodes valid() et cancel() gère les cas de fermeture et lance la méthode close() -> Ajout de la méthode openHTML() pour l'ouverture de la LSsmoothbox avec un code HTML passé en paramètre -> Ajout de la méthode setOption() - LSrelation & LSformElement_select_object : -> Utilisation du principe d'évenement de la LSsmoothbox plutôt que du refreshElement -> Utilisation de la méthode asNew() pour eviter tout problème de concurence - LSdefault : Ajout de la méthode displayInfos()
2008-09-25 17:15:33 +02:00
if (!call_user_func('LSaddon_'. $addon .'_support')) {
LSerror :: addErrorCode('LSsession_02',$addon);
return false;
- LSview : ajout de input hidden pour contenir les informations du type et du DN de l'objet affiché. - LSmail : Ajout d'une fonctionalité d'envoie de mail depuis l'interface. -> Modification de LSformElement_mail pour utiliser cette fonctionalité -> Agrémentation du fichier index_ajax.php -> Ajout d'un LSaddons :: mail - LSsession : -> Ajout d'une méthode getEmailSender() -> Utilisation de la méthode getEmailSender() pour la partie de récupération de mot de passe -> Revue des méthodes loadLSaddon() et loadLSaddons() - LSconfirmBox : -> Ajout de binding onClose() et onCancel() - LSsmoothbox : -> Déport de la creation de la structure dans la méthode build() -> Suppression du principe de refreshElement au profit de binding sur les évenements onClose, onValid et onCancel -> Ajout des méthodes addEvent() et fireEvent() -> Suppression de la méthode setRefreshElement() -> Ajout de la méthode asNew() pour remettre l'objet dans son état d'origine pour l'utilisation simultané de l'objet par plusieurs autres -> Vérification lors du clique sur le closeBtn qu'une précédente confirmBox n'est pas déjà ouvert -> La méthode close() ne fait plus que fermer la LSsmoothbox et les méthodes valid() et cancel() gère les cas de fermeture et lance la méthode close() -> Ajout de la méthode openHTML() pour l'ouverture de la LSsmoothbox avec un code HTML passé en paramètre -> Ajout de la méthode setOption() - LSrelation & LSformElement_select_object : -> Utilisation du principe d'évenement de la LSsmoothbox plutôt que du refreshElement -> Utilisation de la méthode asNew() pour eviter tout problème de concurence - LSdefault : Ajout de la méthode displayInfos()
2008-09-25 17:15:33 +02:00
}
self :: $loadedAddons[] = $addon;
- LSview : ajout de input hidden pour contenir les informations du type et du DN de l'objet affiché. - LSmail : Ajout d'une fonctionalité d'envoie de mail depuis l'interface. -> Modification de LSformElement_mail pour utiliser cette fonctionalité -> Agrémentation du fichier index_ajax.php -> Ajout d'un LSaddons :: mail - LSsession : -> Ajout d'une méthode getEmailSender() -> Utilisation de la méthode getEmailSender() pour la partie de récupération de mot de passe -> Revue des méthodes loadLSaddon() et loadLSaddons() - LSconfirmBox : -> Ajout de binding onClose() et onCancel() - LSsmoothbox : -> Déport de la creation de la structure dans la méthode build() -> Suppression du principe de refreshElement au profit de binding sur les évenements onClose, onValid et onCancel -> Ajout des méthodes addEvent() et fireEvent() -> Suppression de la méthode setRefreshElement() -> Ajout de la méthode asNew() pour remettre l'objet dans son état d'origine pour l'utilisation simultané de l'objet par plusieurs autres -> Vérification lors du clique sur le closeBtn qu'une précédente confirmBox n'est pas déjà ouvert -> La méthode close() ne fait plus que fermer la LSsmoothbox et les méthodes valid() et cancel() gère les cas de fermeture et lance la méthode close() -> Ajout de la méthode openHTML() pour l'ouverture de la LSsmoothbox avec un code HTML passé en paramètre -> Ajout de la méthode setOption() - LSrelation & LSformElement_select_object : -> Utilisation du principe d'évenement de la LSsmoothbox plutôt que du refreshElement -> Utilisation de la méthode asNew() pour eviter tout problème de concurence - LSdefault : Ajout de la méthode displayInfos()
2008-09-25 17:15:33 +02:00
return true;
}
return false;
}
/**
* Load an LdapSaisie resource file
*
* @param string $path The resource file path/name to load, relative to LS_RESOURCE_DIR
* (Example : supann/populations.php)
* @param bool $warn (Optionnel) Trigger LSsession_22 error if an error occured loading this
* resource file (Default: true)
*
* @author Benjamin Renard <brenard@easter-eggs.com
*
* @return boolean true on success, otherwise false
*/
public static function loadResourceFile($path, $warn=true) {
if (self :: includeFile(LS_RESOURCE_DIR . $path, false, $warn))
return true;
if ($warn)
LSerror :: addErrorCode('LSsession_22', $path);
return False;
}
/**
2021-08-25 18:02:37 +02:00
* Load LSauth
*
* @author Benjamin Renard <brenard@easter-eggs.com
2020-04-29 15:54:21 +02:00
*
* @return bool True on success, false otherwise
*/
public static function loadLSauth() {
if (self :: loadLSclass('LSauth')) {
return true;
}
else {
LSerror :: addErrorCode('LSsession_05','LSauth');
}
return false;
}
2020-04-29 15:15:41 +02:00
/**
* Load LdapSaisie CLI class
*
* @author Benjamin Renard <brenard@easter-eggs.com
*
* @return boolean true if loaded, false otherwise.
2020-04-29 15:15:41 +02:00
*/
public static function loadLScli() {
if (self :: loadLSclass('LScli')) {
return true;
}
else {
LSerror :: addErrorCode('LSsession_05','LScli');
}
return false;
2020-04-29 15:15:41 +02:00
}
/**
* Load globally required LSaddons
*
* Load LSaddons list in $GLOBALS['LSaddons']['loads']
*
* @return boolean True on success, False otherwise
*/
public static function loadLSaddons() {
$conf = LSconfig :: get('LSaddons.loads');
if(!is_array($conf)) {
LSerror :: addErrorCode('LSsession_01',"LSaddons['loads']");
return false;
}
$error = false;
foreach ($conf as $addon) {
if (!self :: loadLSaddon($addon))
$false = true;
}
return !$error;
}
/**
* Load and start LSlang, the I18N manager
2020-04-29 15:54:21 +02:00
*
* @param string|null $lang The lang (optional, default: see LSlang :: setLocale())
* @param string|null $encoding The encoding (optional, default: see LSlang :: setLocale())
2020-04-29 15:54:21 +02:00
*
* @author Benjamin Renard <brenard@easter-eggs.com
2020-04-29 15:54:21 +02:00
*
* @return boolean true if LSlang started, false otherwise
*/
private static function startLSlang($lang=null, $encoding=null) {
if(!self :: loadLSclass('LSlang')) {
return false;
- functions : -> Ajout de la fonction __() : fonction de traduction utilisant à la fois le tableau globale LSlang et gettext pour traduire les messages qu'on lui passe. -> Ajout de la fonction tr() : fonction utilisable depuis les templates pour traduire une variable smarty. - LSexample : -> Utilisation de la traduction via __() plutôt que gettext - LSdefault : -> Creation d'un template pour la gestion des outils apporté par LSdefaut (LSerror, LSdebug, ...) -> Ajout de méthode de gestion de LSlang - LSsession : - Login/RecoverPassword : Utilisation du template LSdefault - Gestion de la traduction : -> Ajout de la méthode setLocale() définissant la langue de l'interface. -> Ajout des méthodes getLangList() et localeExist() -> Le session_start() se fait dans l'initialize désormais (pour gérer la langue même déconnecté) -> Méthode setLdapServer() : rédifinition de la locale avec setLocale() -> Ajout de LSlang : outil JS permetant dans l'interface de choisir sa langue - Config : -> De manière général, il ne doit plus y avoir d'appel de la fonction _() dans les fichiers de config, les chaînes sont données non traduite, et la traduction se fera lors de leur utilisation. -> Tout les labels et messages déclarer dans la config, est maintenant traduit du coté code PHP avec la fonction __() -> L'enconding et la langue sont désormais géré indépendament - ViewList : Les noms des boutons (New,Refresh,...) ne sont plus traduit du côté PHP mais dans le template à cause de leur mise en cache. - Documentation : -> Mise à jour relative en changement de paramètres de configuration -> Ajout des informations sur les variables et constantes indépendantes du fichier de configuration config.inc.php -> Mise à jour du fichier INSTALL avec les informations de la documentation
2009-03-19 18:42:51 +01:00
}
LSlang :: setLocale($lang, $encoding);
return true;
- functions : -> Ajout de la fonction __() : fonction de traduction utilisant à la fois le tableau globale LSlang et gettext pour traduire les messages qu'on lui passe. -> Ajout de la fonction tr() : fonction utilisable depuis les templates pour traduire une variable smarty. - LSexample : -> Utilisation de la traduction via __() plutôt que gettext - LSdefault : -> Creation d'un template pour la gestion des outils apporté par LSdefaut (LSerror, LSdebug, ...) -> Ajout de méthode de gestion de LSlang - LSsession : - Login/RecoverPassword : Utilisation du template LSdefault - Gestion de la traduction : -> Ajout de la méthode setLocale() définissant la langue de l'interface. -> Ajout des méthodes getLangList() et localeExist() -> Le session_start() se fait dans l'initialize désormais (pour gérer la langue même déconnecté) -> Méthode setLdapServer() : rédifinition de la locale avec setLocale() -> Ajout de LSlang : outil JS permetant dans l'interface de choisir sa langue - Config : -> De manière général, il ne doit plus y avoir d'appel de la fonction _() dans les fichiers de config, les chaînes sont données non traduite, et la traduction se fera lors de leur utilisation. -> Tout les labels et messages déclarer dans la config, est maintenant traduit du coté code PHP avec la fonction __() -> L'enconding et la langue sont désormais géré indépendament - ViewList : Les noms des boutons (New,Refresh,...) ne sont plus traduit du côté PHP mais dans le template à cause de leur mise en cache. - Documentation : -> Mise à jour relative en changement de paramètres de configuration -> Ajout des informations sur les variables et constantes indépendantes du fichier de configuration config.inc.php -> Mise à jour du fichier INSTALL avec les informations de la documentation
2009-03-19 18:42:51 +01:00
}
/**
* Initialize LdapSaisie
*
* @param string|null $lang The lang (optional, default: see LSlang :: setLocale())
* @param string|null $encoding The encoding (optional, default: see LSlang :: setLocale())
*
* @return boolean True if initialized, false otherwise
*/
public static function initialize($lang=null, $encoding=null) {
if (self :: $initialized)
return true;
try {
if (!self :: startLSconfig()) {
return false;
}
self :: startLSerror();
2019-06-28 18:00:37 +02:00
self :: startLSlog();
self :: loadLScli();
self :: startLStemplate();
self :: startLSurl();
2020-04-29 15:15:41 +02:00
if (php_sapi_name() != "cli")
session_start();
self :: startLSlang($lang, $encoding);
self :: loadLSaddons();
self :: loadLSauth();
}
catch (Exception $e) {
die('LSsession : fail to initialize session. Error : '.$e->getMessage());
- functions : -> Ajout de la fonction __() : fonction de traduction utilisant à la fois le tableau globale LSlang et gettext pour traduire les messages qu'on lui passe. -> Ajout de la fonction tr() : fonction utilisable depuis les templates pour traduire une variable smarty. - LSexample : -> Utilisation de la traduction via __() plutôt que gettext - LSdefault : -> Creation d'un template pour la gestion des outils apporté par LSdefaut (LSerror, LSdebug, ...) -> Ajout de méthode de gestion de LSlang - LSsession : - Login/RecoverPassword : Utilisation du template LSdefault - Gestion de la traduction : -> Ajout de la méthode setLocale() définissant la langue de l'interface. -> Ajout des méthodes getLangList() et localeExist() -> Le session_start() se fait dans l'initialize désormais (pour gérer la langue même déconnecté) -> Méthode setLdapServer() : rédifinition de la locale avec setLocale() -> Ajout de LSlang : outil JS permetant dans l'interface de choisir sa langue - Config : -> De manière général, il ne doit plus y avoir d'appel de la fonction _() dans les fichiers de config, les chaînes sont données non traduite, et la traduction se fera lors de leur utilisation. -> Tout les labels et messages déclarer dans la config, est maintenant traduit du coté code PHP avec la fonction __() -> L'enconding et la langue sont désormais géré indépendament - ViewList : Les noms des boutons (New,Refresh,...) ne sont plus traduit du côté PHP mais dans le template à cause de leur mise en cache. - Documentation : -> Mise à jour relative en changement de paramètres de configuration -> Ajout des informations sur les variables et constantes indépendantes du fichier de configuration config.inc.php -> Mise à jour du fichier INSTALL avec les informations de la documentation
2009-03-19 18:42:51 +01:00
}
self :: $initialized = true;
return true;
}
/**
2021-08-25 18:02:37 +02:00
* Start and initialize LdapSaisie session
*
* LSsession initialization :
* - initiale LdapSaisie main components (LSerror, LSlog, LScli, LStemplate, ...)
* - restore connected user info from session or trigger authentication (or password recovery)
* - restore other session info from session (cache / tmp files)
* - start LDAP connection
* - handle logout (if $_GET['LSsession_logout'] is present)
* - load connected user profiles and access (if connected)
* - enable/disable global search
*
* @return boolean True on intiatialization success and if user is authenticed, false otherwise.
*/
public static function startLSsession() {
if (!self :: initialize()) {
return false;
}
2020-04-29 15:54:21 +02:00
if(isset($_SESSION['LSsession']['LSuserObjectType']) && isset($_SESSION['LSsession']['dn']) && !isset($_GET['LSsession_recoverPassword'])) {
2020-05-08 15:51:21 +02:00
self :: log_debug('existing session');
// --------------------- Session existante --------------------- //
self :: $topDn = $_SESSION['LSsession']['topDn'];
self :: $dn = $_SESSION['LSsession']['dn'];
self :: $LSuserObjectType = $_SESSION['LSsession']['LSuserObjectType'];
self :: $rdn = $_SESSION['LSsession']['rdn'];
self :: $ldapServerId = $_SESSION['LSsession']['ldapServerId'];
self :: $tmp_file = $_SESSION['LSsession']['tmp_file'];
self :: $userLDAPcreds = $_SESSION['LSsession']['userLDAPcreds'];
2020-04-29 15:54:21 +02:00
if ( self :: cacheLSprofiles() && !isset($_REQUEST['LSsession_refresh']) ) {
self :: setLdapServer(self :: $ldapServerId);
if (!LSauth :: start()) {
2020-05-08 15:51:21 +02:00
self :: log_error("startLSsession(): can't start LSauth -> stop");
return false;
}
self :: $LSprofiles = $_SESSION['LSsession']['LSprofiles'];
self :: $LSaccess = $_SESSION['LSsession']['LSaccess'];
2015-08-21 17:51:52 +02:00
self :: $LSaddonsViewsAccess = $_SESSION['LSsession']['LSaddonsViewsAccess'];
if (!self :: LSldapConnect())
return false;
}
else {
self :: setLdapServer(self :: $ldapServerId);
if (!LSauth :: start()) {
2020-05-08 15:51:21 +02:00
self :: log_error("startLSsession(): can't start LSauth -> stop");
return false;
}
if (!self :: LSldapConnect())
return false;
self :: loadLSprofiles();
}
2020-04-29 15:54:21 +02:00
if ( self :: cacheSudDn() && (!isset($_REQUEST['LSsession_refresh'])) ) {
self :: $_subDnLdapServer = ((isset($_SESSION['LSsession_subDnLdapServer']))?$_SESSION['LSsession_subDnLdapServer']:NULL);
}
2020-04-29 15:54:21 +02:00
if (!self :: loadLSobject(self :: $LSuserObjectType)) {
return false;
}
2019-05-21 12:06:24 +02:00
LStemplate :: assign('globalSearch', self :: globalSearch());
2020-04-29 15:54:21 +02:00
2010-03-10 19:36:23 +01:00
if (isset($_GET['LSsession_logout'])) {
2019-03-27 18:02:04 +01:00
// Trigger LSauth logout
LSauth :: logout();
2019-03-27 18:02:04 +01:00
// Delete temporaries files
2010-03-10 19:36:23 +01:00
if (is_array($_SESSION['LSsession']['tmp_file'])) {
self :: $tmp_file = $_SESSION['LSsession']['tmp_file'];
}
self :: deleteTmpFile();
2019-03-27 18:02:04 +01:00
// Destroy local session
2010-03-10 19:36:23 +01:00
unset($_SESSION['LSsession']);
2019-03-27 18:02:04 +01:00
session_destroy();
// Trigger LSauth after logout
LSauth :: afterLogout();
// Redirect user on home page
LSurl :: redirect();
return false;
2010-03-10 19:36:23 +01:00
}
2020-04-29 15:54:21 +02:00
if ( !self :: cacheLSprofiles() || isset($_REQUEST['LSsession_refresh']) ) {
self :: loadLSprofiles();
self :: loadLSaccess();
2015-08-21 17:51:52 +02:00
self :: loadLSaddonsViewsAccess();
self :: saveContextInfos();
}
2020-04-29 15:54:21 +02:00
LStemplate :: assign('LSsession_username',self :: getLSuserObject() -> getDisplayName());
2020-04-29 15:54:21 +02:00
2020-08-06 16:43:35 +02:00
if (isset($_POST['LSsession_topDn']) && $_POST['LSsession_topDn'])
self :: setSubDn($_POST['LSsession_topDn']);
2020-04-29 15:54:21 +02:00
return true;
2020-04-29 15:54:21 +02:00
}
else {
// --------------------- Session inexistante --------------------- //
if (isset($_GET['LSsession_recoverPassword'])) {
session_destroy();
}
// Session inexistante
if (isset($_POST['LSsession_ldapserver'])) {
self :: setLdapServer($_POST['LSsession_ldapserver']);
}
else {
self :: setLdapServer(0);
}
2020-04-29 15:54:21 +02:00
// Connexion au serveur LDAP
if (self :: LSldapConnect()) {
// topDn
if (isset($_POST['LSsession_topDn']) && $_POST['LSsession_topDn'] != '' ){
self :: setSubDn($_POST['LSsession_topDn']);
}
else {
self :: setSubDn(self :: $ldapServer['ldap_config']['basedn']);
}
2020-04-29 15:54:21 +02:00
if (!LSauth :: start()) {
2020-05-08 15:51:21 +02:00
self :: log_error("startLSsession(): can't start LSauth -> stop");
return false;
}
2020-04-29 15:54:21 +02:00
if (isset($_GET['LSsession_recoverPassword'])) {
$recoveryPasswordInfos = self :: recoverPasswd (
(isset($_REQUEST['LSsession_user'])?$_REQUEST['LSsession_user']:''),
(isset($_GET['recoveryHash'])?$_GET['recoveryHash']:'')
);
}
else {
$LSuserObject = LSauth :: forceAuthentication();
if ($LSuserObject) {
// Authentication successful
self :: $LSuserObject = $LSuserObject;
self :: $LSuserObjectType = $LSuserObject -> getType();
self :: $dn = $LSuserObject->getValue('dn');
self :: $rdn = $LSuserObject->getValue('rdn');
if (
isset(self :: $ldapServer['useUserCredentials']) &&
self :: $ldapServer['useUserCredentials']
) {
if (
isset(self :: $ldapServer['useAuthzProxyControl']) &&
self :: $ldapServer['useAuthzProxyControl']
) {
if (!LSldap :: setAuthzProxyControl(self :: $dn)) {
return false;
}
}
else {
self :: $userLDAPcreds = LSauth :: getLDAPcredentials($LSuserObject);
if (!is_array(self :: $userLDAPcreds)) {
LSerror :: addErrorCode('LSsession_14');
self :: $userLDAPcreds = false;
return false;
}
if (!LSldap :: reconnectAs(
self :: $userLDAPcreds['dn'],
self :: $userLDAPcreds['pwd'],
self :: $ldapServer['ldap_config']
)) {
LSerror :: addErrorCode('LSsession_15');
return false;
}
}
}
self :: loadLSprofiles();
self :: loadLSaccess();
2015-08-21 17:51:52 +02:00
self :: loadLSaddonsViewsAccess();
LStemplate :: assign('LSsession_username',self :: getLSuserObject() -> getDisplayName());
2019-05-21 12:06:24 +02:00
LStemplate :: assign('globalSearch', self :: globalSearch());
self :: saveContextInfos();
return true;
}
}
}
else {
LSerror :: addErrorCode('LSsession_09');
}
2020-04-29 15:54:21 +02:00
if (self :: $ldapServerId) {
LStemplate :: assign('ldapServerId',self :: $ldapServerId);
}
if (isset($recoveryPasswordInfos)) {
self :: displayRecoverPasswordForm($recoveryPasswordInfos);
}
elseif(LSauth :: displayLoginForm()) {
self :: displayLoginForm();
}
else {
2020-05-07 12:16:12 +02:00
self :: setTemplate('base.tpl');
LSerror :: addErrorCode('LSsession_10');
}
return false;
}
}
2020-04-29 15:15:41 +02:00
/**
* Initialize a CLI session for LdapSaisie
*
* @return boolean True if intialized, false otherwise.
2020-04-29 15:15:41 +02:00
*/
public static function startCliLSsession() {
if (php_sapi_name() != "cli") return false;
if (!self :: initialize()) return false;
if (!self :: loadLScli()) return false;
2020-04-29 15:15:41 +02:00
return True;
}
- LSsearch/LSsearchEntry : Added a new classes to doing and exploit ldap object search -> view/select => change to use it (php+template+js) -> LSattr_html_select_object/LSattr_html_select_list => change to use it -> LSldapObject : -> change listObjectsName() / searchObject() / getSelectArray() / listObjects() -> comment search() function -> Add triggers to clean cache -> LSpeople : Update search config -> LSsession : Change function to use it : - getSubDnLdapServer() - loadLSprofiles() - LSrelation : Deplace error codes declaration from LSsession in class file - LSldapObject : -> change getObjectFilter() / getLabel() / getSubDnValue() / getSubDnName() for can call then staticaly -> Add afterModify() function and trigger -> Change getObjectFilter() / listObjectsInRelation() to use Net_LDAP2_Filter -> Add __get() function -> Move one LSerror code for LSrelation function from LSsession class file -> Add a global variable to save cached data ($cache) -> Change subDn and subDnName access methods - LSauth : Move LSsession auth procedure in a dedicated class -> LSsession : Change startLSsession() to use it - LSsession : -> Add getRootDn() function -> Fix getTopDn() to return root DN if no topDn is currently defined -> Create dedicated functions to support recoveryPassword mecanism : - recoverPasswd() - recoverPasswdSendMail() - recoverPasswdFirstStep() - recoverPasswdSecondStep -> Customize LSdebug return and display (php+js) -> Clean unused error codes -> Move LSrelation error codes -> Comment ajax method
2009-10-30 01:03:17 +01:00
/**
* Do recover password
2020-04-29 15:54:21 +02:00
*
* @param string $username The submited username
* @param string $recoveryHash The submited recoveryHash
2020-04-29 15:54:21 +02:00
*
* @return array|false The recoveryPassword infos for template, or false in case of error
- LSsearch/LSsearchEntry : Added a new classes to doing and exploit ldap object search -> view/select => change to use it (php+template+js) -> LSattr_html_select_object/LSattr_html_select_list => change to use it -> LSldapObject : -> change listObjectsName() / searchObject() / getSelectArray() / listObjects() -> comment search() function -> Add triggers to clean cache -> LSpeople : Update search config -> LSsession : Change function to use it : - getSubDnLdapServer() - loadLSprofiles() - LSrelation : Deplace error codes declaration from LSsession in class file - LSldapObject : -> change getObjectFilter() / getLabel() / getSubDnValue() / getSubDnName() for can call then staticaly -> Add afterModify() function and trigger -> Change getObjectFilter() / listObjectsInRelation() to use Net_LDAP2_Filter -> Add __get() function -> Move one LSerror code for LSrelation function from LSsession class file -> Add a global variable to save cached data ($cache) -> Change subDn and subDnName access methods - LSauth : Move LSsession auth procedure in a dedicated class -> LSsession : Change startLSsession() to use it - LSsession : -> Add getRootDn() function -> Fix getTopDn() to return root DN if no topDn is currently defined -> Create dedicated functions to support recoveryPassword mecanism : - recoverPasswd() - recoverPasswdSendMail() - recoverPasswdFirstStep() - recoverPasswdSecondStep -> Customize LSdebug return and display (php+js) -> Clean unused error codes -> Move LSrelation error codes -> Comment ajax method
2009-10-30 01:03:17 +01:00
**/
private static function recoverPasswd($username, $recoveryHash) {
// Check feature is enabled and LSmail available
if (!isset(self :: $ldapServer['recoverPassword']) || !self :: loadLSaddon('mail')) {
LSerror :: addErrorCode('LSsession_18');
return false;
}
// Start LSauth
if (!LSauth :: start()) {
self :: log_error("recoverPasswd(): can't start LSauth -> stop");
return false;
}
// Search user by recoveryHash or username
if (!empty($recoveryHash)) {
$users = array();
$filter = Net_LDAP2_Filter::create(
self :: $ldapServer['recoverPassword']['recoveryHashAttr'],
'equals',
$recoveryHash
);
foreach (LSauth :: getAuthObjectTypes() as $objType => $objParams) {
if (!self :: loadLSobject($objType))
return false;
$authobject = new $objType();
$users = array_merge(
$users,
$authobject -> listObjects($filter, self :: getTopDn(), array('onlyAccessible' => false))
- LSsearch/LSsearchEntry : Added a new classes to doing and exploit ldap object search -> view/select => change to use it (php+template+js) -> LSattr_html_select_object/LSattr_html_select_list => change to use it -> LSldapObject : -> change listObjectsName() / searchObject() / getSelectArray() / listObjects() -> comment search() function -> Add triggers to clean cache -> LSpeople : Update search config -> LSsession : Change function to use it : - getSubDnLdapServer() - loadLSprofiles() - LSrelation : Deplace error codes declaration from LSsession in class file - LSldapObject : -> change getObjectFilter() / getLabel() / getSubDnValue() / getSubDnName() for can call then staticaly -> Add afterModify() function and trigger -> Change getObjectFilter() / listObjectsInRelation() to use Net_LDAP2_Filter -> Add __get() function -> Move one LSerror code for LSrelation function from LSsession class file -> Add a global variable to save cached data ($cache) -> Change subDn and subDnName access methods - LSauth : Move LSsession auth procedure in a dedicated class -> LSsession : Change startLSsession() to use it - LSsession : -> Add getRootDn() function -> Fix getTopDn() to return root DN if no topDn is currently defined -> Create dedicated functions to support recoveryPassword mecanism : - recoverPasswd() - recoverPasswdSendMail() - recoverPasswdFirstStep() - recoverPasswdSecondStep -> Customize LSdebug return and display (php+js) -> Clean unused error codes -> Move LSrelation error codes -> Comment ajax method
2009-10-30 01:03:17 +01:00
);
}
}
elseif (!empty($username)) {
$users = LSauth :: username2LSobjects($username);
if (!is_array($users))
return false;
}
else {
self :: log_debug('recoverPasswd(): no username or recoveryHash provided.');
return false;
}
// Check user found (and not duplicated)
$nbresult = count($users);
if ($nbresult == 0) {
self :: log_debug('recoverPasswd(): incorrect hash/username');
LSerror :: addErrorCode('LSsession_06');
return false;
}
elseif ($nbresult > 1) {
self :: log_debug("recoverPasswd(): duplicated user found with hash='$recoveryHash' / username='$username'");
LSerror :: addErrorCode('LSsession_07');
return false;
}
2020-04-29 15:54:21 +02:00
$user = array_pop($users);
$rdn = $user -> getValue('rdn');
$username = $rdn[0];
self :: log_debug("recoverPasswd(): user found, username = '$username'");
2020-04-29 15:54:21 +02:00
self :: log_debug("recoverPasswd(): start recovering password");
$emailAddress = $user -> getValue(self :: $ldapServer['recoverPassword']['mailAttr']);
$emailAddress = $emailAddress[0];
if (!checkEmail($emailAddress)) {
LSerror :: addErrorCode('LSsession_19');
return false;
}
self :: log_debug("recoverPasswd(): Email = '$emailAddress'");
self :: $dn = $user -> getDn();
//
$recoveryPasswordInfos = array();
// First step : send recoveryHash
if (empty($recoveryHash)) {
$hash = self :: recoverPasswdFirstStep($user);
if ($hash) {
if (self :: recoverPasswdSendMail($emailAddress, 1, $hash)) {
// Recovery hash sent
$recoveryPasswordInfos['recoveryHashMail'] = $emailAddress;
- LSsearch/LSsearchEntry : Added a new classes to doing and exploit ldap object search -> view/select => change to use it (php+template+js) -> LSattr_html_select_object/LSattr_html_select_list => change to use it -> LSldapObject : -> change listObjectsName() / searchObject() / getSelectArray() / listObjects() -> comment search() function -> Add triggers to clean cache -> LSpeople : Update search config -> LSsession : Change function to use it : - getSubDnLdapServer() - loadLSprofiles() - LSrelation : Deplace error codes declaration from LSsession in class file - LSldapObject : -> change getObjectFilter() / getLabel() / getSubDnValue() / getSubDnName() for can call then staticaly -> Add afterModify() function and trigger -> Change getObjectFilter() / listObjectsInRelation() to use Net_LDAP2_Filter -> Add __get() function -> Move one LSerror code for LSrelation function from LSsession class file -> Add a global variable to save cached data ($cache) -> Change subDn and subDnName access methods - LSauth : Move LSsession auth procedure in a dedicated class -> LSsession : Change startLSsession() to use it - LSsession : -> Add getRootDn() function -> Fix getTopDn() to return root DN if no topDn is currently defined -> Create dedicated functions to support recoveryPassword mecanism : - recoverPasswd() - recoverPasswdSendMail() - recoverPasswdFirstStep() - recoverPasswdSecondStep -> Customize LSdebug return and display (php+js) -> Clean unused error codes -> Move LSrelation error codes -> Comment ajax method
2009-10-30 01:03:17 +01:00
}
}
}
// Second step : generate and send new password
else {
$pwd = self :: recoverPasswdSecondStep($user);
if ($pwd) {
if (self :: recoverPasswdSendMail($emailAddress, 2, $pwd)) {
// New password sent
$recoveryPasswordInfos['newPasswordMail'] = $emailAddress;
- LSsearch/LSsearchEntry : Added a new classes to doing and exploit ldap object search -> view/select => change to use it (php+template+js) -> LSattr_html_select_object/LSattr_html_select_list => change to use it -> LSldapObject : -> change listObjectsName() / searchObject() / getSelectArray() / listObjects() -> comment search() function -> Add triggers to clean cache -> LSpeople : Update search config -> LSsession : Change function to use it : - getSubDnLdapServer() - loadLSprofiles() - LSrelation : Deplace error codes declaration from LSsession in class file - LSldapObject : -> change getObjectFilter() / getLabel() / getSubDnValue() / getSubDnName() for can call then staticaly -> Add afterModify() function and trigger -> Change getObjectFilter() / listObjectsInRelation() to use Net_LDAP2_Filter -> Add __get() function -> Move one LSerror code for LSrelation function from LSsession class file -> Add a global variable to save cached data ($cache) -> Change subDn and subDnName access methods - LSauth : Move LSsession auth procedure in a dedicated class -> LSsession : Change startLSsession() to use it - LSsession : -> Add getRootDn() function -> Fix getTopDn() to return root DN if no topDn is currently defined -> Create dedicated functions to support recoveryPassword mecanism : - recoverPasswd() - recoverPasswdSendMail() - recoverPasswdFirstStep() - recoverPasswdSecondStep -> Customize LSdebug return and display (php+js) -> Clean unused error codes -> Move LSrelation error codes -> Comment ajax method
2009-10-30 01:03:17 +01:00
}
}
}
return $recoveryPasswordInfos;
}
2020-04-29 15:54:21 +02:00
- LSsearch/LSsearchEntry : Added a new classes to doing and exploit ldap object search -> view/select => change to use it (php+template+js) -> LSattr_html_select_object/LSattr_html_select_list => change to use it -> LSldapObject : -> change listObjectsName() / searchObject() / getSelectArray() / listObjects() -> comment search() function -> Add triggers to clean cache -> LSpeople : Update search config -> LSsession : Change function to use it : - getSubDnLdapServer() - loadLSprofiles() - LSrelation : Deplace error codes declaration from LSsession in class file - LSldapObject : -> change getObjectFilter() / getLabel() / getSubDnValue() / getSubDnName() for can call then staticaly -> Add afterModify() function and trigger -> Change getObjectFilter() / listObjectsInRelation() to use Net_LDAP2_Filter -> Add __get() function -> Move one LSerror code for LSrelation function from LSsession class file -> Add a global variable to save cached data ($cache) -> Change subDn and subDnName access methods - LSauth : Move LSsession auth procedure in a dedicated class -> LSsession : Change startLSsession() to use it - LSsession : -> Add getRootDn() function -> Fix getTopDn() to return root DN if no topDn is currently defined -> Create dedicated functions to support recoveryPassword mecanism : - recoverPasswd() - recoverPasswdSendMail() - recoverPasswdFirstStep() - recoverPasswdSecondStep -> Customize LSdebug return and display (php+js) -> Clean unused error codes -> Move LSrelation error codes -> Comment ajax method
2009-10-30 01:03:17 +01:00
/**
* Send recover password mail
2020-04-29 15:54:21 +02:00
*
* @param string $mail The user's mail
* @param boolean $step The step
* @param string $info The info for formatted message
2020-04-29 15:54:21 +02:00
*
* @return boolean True on success or False
- LSsearch/LSsearchEntry : Added a new classes to doing and exploit ldap object search -> view/select => change to use it (php+template+js) -> LSattr_html_select_object/LSattr_html_select_list => change to use it -> LSldapObject : -> change listObjectsName() / searchObject() / getSelectArray() / listObjects() -> comment search() function -> Add triggers to clean cache -> LSpeople : Update search config -> LSsession : Change function to use it : - getSubDnLdapServer() - loadLSprofiles() - LSrelation : Deplace error codes declaration from LSsession in class file - LSldapObject : -> change getObjectFilter() / getLabel() / getSubDnValue() / getSubDnName() for can call then staticaly -> Add afterModify() function and trigger -> Change getObjectFilter() / listObjectsInRelation() to use Net_LDAP2_Filter -> Add __get() function -> Move one LSerror code for LSrelation function from LSsession class file -> Add a global variable to save cached data ($cache) -> Change subDn and subDnName access methods - LSauth : Move LSsession auth procedure in a dedicated class -> LSsession : Change startLSsession() to use it - LSsession : -> Add getRootDn() function -> Fix getTopDn() to return root DN if no topDn is currently defined -> Create dedicated functions to support recoveryPassword mecanism : - recoverPasswd() - recoverPasswdSendMail() - recoverPasswdFirstStep() - recoverPasswdSecondStep -> Customize LSdebug return and display (php+js) -> Clean unused error codes -> Move LSrelation error codes -> Comment ajax method
2009-10-30 01:03:17 +01:00
**/
private static function recoverPasswdSendMail($mail,$step,$info) {
// Header des mails
$sendParams=array();
if (self :: $ldapServer['recoverPassword']['recoveryEmailSender']) {
$sendParams['From']=self :: $ldapServer['recoverPassword']['recoveryEmailSender'];
}
2020-04-29 15:54:21 +02:00
- LSsearch/LSsearchEntry : Added a new classes to doing and exploit ldap object search -> view/select => change to use it (php+template+js) -> LSattr_html_select_object/LSattr_html_select_list => change to use it -> LSldapObject : -> change listObjectsName() / searchObject() / getSelectArray() / listObjects() -> comment search() function -> Add triggers to clean cache -> LSpeople : Update search config -> LSsession : Change function to use it : - getSubDnLdapServer() - loadLSprofiles() - LSrelation : Deplace error codes declaration from LSsession in class file - LSldapObject : -> change getObjectFilter() / getLabel() / getSubDnValue() / getSubDnName() for can call then staticaly -> Add afterModify() function and trigger -> Change getObjectFilter() / listObjectsInRelation() to use Net_LDAP2_Filter -> Add __get() function -> Move one LSerror code for LSrelation function from LSsession class file -> Add a global variable to save cached data ($cache) -> Change subDn and subDnName access methods - LSauth : Move LSsession auth procedure in a dedicated class -> LSsession : Change startLSsession() to use it - LSsession : -> Add getRootDn() function -> Fix getTopDn() to return root DN if no topDn is currently defined -> Create dedicated functions to support recoveryPassword mecanism : - recoverPasswd() - recoverPasswdSendMail() - recoverPasswdFirstStep() - recoverPasswdSecondStep -> Customize LSdebug return and display (php+js) -> Clean unused error codes -> Move LSrelation error codes -> Comment ajax method
2009-10-30 01:03:17 +01:00
if ($step==1) {
$subject = self :: $ldapServer['recoverPassword']['recoveryHashMail']['subject'];
$msg = getFData(
self :: $ldapServer['recoverPassword']['recoveryHashMail']['msg'],
LSurl :: get_public_absolute_url('index')."?LSsession_recoverPassword&recoveryHash=$info"
- LSsearch/LSsearchEntry : Added a new classes to doing and exploit ldap object search -> view/select => change to use it (php+template+js) -> LSattr_html_select_object/LSattr_html_select_list => change to use it -> LSldapObject : -> change listObjectsName() / searchObject() / getSelectArray() / listObjects() -> comment search() function -> Add triggers to clean cache -> LSpeople : Update search config -> LSsession : Change function to use it : - getSubDnLdapServer() - loadLSprofiles() - LSrelation : Deplace error codes declaration from LSsession in class file - LSldapObject : -> change getObjectFilter() / getLabel() / getSubDnValue() / getSubDnName() for can call then staticaly -> Add afterModify() function and trigger -> Change getObjectFilter() / listObjectsInRelation() to use Net_LDAP2_Filter -> Add __get() function -> Move one LSerror code for LSrelation function from LSsession class file -> Add a global variable to save cached data ($cache) -> Change subDn and subDnName access methods - LSauth : Move LSsession auth procedure in a dedicated class -> LSsession : Change startLSsession() to use it - LSsession : -> Add getRootDn() function -> Fix getTopDn() to return root DN if no topDn is currently defined -> Create dedicated functions to support recoveryPassword mecanism : - recoverPasswd() - recoverPasswdSendMail() - recoverPasswdFirstStep() - recoverPasswdSecondStep -> Customize LSdebug return and display (php+js) -> Clean unused error codes -> Move LSrelation error codes -> Comment ajax method
2009-10-30 01:03:17 +01:00
);
}
else {
$subject = self :: $ldapServer['recoverPassword']['newPasswordMail']['subject'];
$msg = getFData(
self :: $ldapServer['recoverPassword']['newPasswordMail']['msg'],
$info
);
}
2020-04-29 15:54:21 +02:00
- LSsearch/LSsearchEntry : Added a new classes to doing and exploit ldap object search -> view/select => change to use it (php+template+js) -> LSattr_html_select_object/LSattr_html_select_list => change to use it -> LSldapObject : -> change listObjectsName() / searchObject() / getSelectArray() / listObjects() -> comment search() function -> Add triggers to clean cache -> LSpeople : Update search config -> LSsession : Change function to use it : - getSubDnLdapServer() - loadLSprofiles() - LSrelation : Deplace error codes declaration from LSsession in class file - LSldapObject : -> change getObjectFilter() / getLabel() / getSubDnValue() / getSubDnName() for can call then staticaly -> Add afterModify() function and trigger -> Change getObjectFilter() / listObjectsInRelation() to use Net_LDAP2_Filter -> Add __get() function -> Move one LSerror code for LSrelation function from LSsession class file -> Add a global variable to save cached data ($cache) -> Change subDn and subDnName access methods - LSauth : Move LSsession auth procedure in a dedicated class -> LSsession : Change startLSsession() to use it - LSsession : -> Add getRootDn() function -> Fix getTopDn() to return root DN if no topDn is currently defined -> Create dedicated functions to support recoveryPassword mecanism : - recoverPasswd() - recoverPasswdSendMail() - recoverPasswdFirstStep() - recoverPasswdSecondStep -> Customize LSdebug return and display (php+js) -> Clean unused error codes -> Move LSrelation error codes -> Comment ajax method
2009-10-30 01:03:17 +01:00
if (!sendMail($mail,$subject,$msg,$sendParams)) {
2020-05-08 15:51:21 +02:00
self :: log_debug("recoverPasswdSendMail($mail, $step): error sending email.");
- LSsearch/LSsearchEntry : Added a new classes to doing and exploit ldap object search -> view/select => change to use it (php+template+js) -> LSattr_html_select_object/LSattr_html_select_list => change to use it -> LSldapObject : -> change listObjectsName() / searchObject() / getSelectArray() / listObjects() -> comment search() function -> Add triggers to clean cache -> LSpeople : Update search config -> LSsession : Change function to use it : - getSubDnLdapServer() - loadLSprofiles() - LSrelation : Deplace error codes declaration from LSsession in class file - LSldapObject : -> change getObjectFilter() / getLabel() / getSubDnValue() / getSubDnName() for can call then staticaly -> Add afterModify() function and trigger -> Change getObjectFilter() / listObjectsInRelation() to use Net_LDAP2_Filter -> Add __get() function -> Move one LSerror code for LSrelation function from LSsession class file -> Add a global variable to save cached data ($cache) -> Change subDn and subDnName access methods - LSauth : Move LSsession auth procedure in a dedicated class -> LSsession : Change startLSsession() to use it - LSsession : -> Add getRootDn() function -> Fix getTopDn() to return root DN if no topDn is currently defined -> Create dedicated functions to support recoveryPassword mecanism : - recoverPasswd() - recoverPasswdSendMail() - recoverPasswdFirstStep() - recoverPasswdSecondStep -> Customize LSdebug return and display (php+js) -> Clean unused error codes -> Move LSrelation error codes -> Comment ajax method
2009-10-30 01:03:17 +01:00
LSerror :: addErrorCode('LSsession_20',4);
return false;
- LSsearch/LSsearchEntry : Added a new classes to doing and exploit ldap object search -> view/select => change to use it (php+template+js) -> LSattr_html_select_object/LSattr_html_select_list => change to use it -> LSldapObject : -> change listObjectsName() / searchObject() / getSelectArray() / listObjects() -> comment search() function -> Add triggers to clean cache -> LSpeople : Update search config -> LSsession : Change function to use it : - getSubDnLdapServer() - loadLSprofiles() - LSrelation : Deplace error codes declaration from LSsession in class file - LSldapObject : -> change getObjectFilter() / getLabel() / getSubDnValue() / getSubDnName() for can call then staticaly -> Add afterModify() function and trigger -> Change getObjectFilter() / listObjectsInRelation() to use Net_LDAP2_Filter -> Add __get() function -> Move one LSerror code for LSrelation function from LSsession class file -> Add a global variable to save cached data ($cache) -> Change subDn and subDnName access methods - LSauth : Move LSsession auth procedure in a dedicated class -> LSsession : Change startLSsession() to use it - LSsession : -> Add getRootDn() function -> Fix getTopDn() to return root DN if no topDn is currently defined -> Create dedicated functions to support recoveryPassword mecanism : - recoverPasswd() - recoverPasswdSendMail() - recoverPasswdFirstStep() - recoverPasswdSecondStep -> Customize LSdebug return and display (php+js) -> Clean unused error codes -> Move LSrelation error codes -> Comment ajax method
2009-10-30 01:03:17 +01:00
}
return true;
}
2020-04-29 15:54:21 +02:00
- LSsearch/LSsearchEntry : Added a new classes to doing and exploit ldap object search -> view/select => change to use it (php+template+js) -> LSattr_html_select_object/LSattr_html_select_list => change to use it -> LSldapObject : -> change listObjectsName() / searchObject() / getSelectArray() / listObjects() -> comment search() function -> Add triggers to clean cache -> LSpeople : Update search config -> LSsession : Change function to use it : - getSubDnLdapServer() - loadLSprofiles() - LSrelation : Deplace error codes declaration from LSsession in class file - LSldapObject : -> change getObjectFilter() / getLabel() / getSubDnValue() / getSubDnName() for can call then staticaly -> Add afterModify() function and trigger -> Change getObjectFilter() / listObjectsInRelation() to use Net_LDAP2_Filter -> Add __get() function -> Move one LSerror code for LSrelation function from LSsession class file -> Add a global variable to save cached data ($cache) -> Change subDn and subDnName access methods - LSauth : Move LSsession auth procedure in a dedicated class -> LSsession : Change startLSsession() to use it - LSsession : -> Add getRootDn() function -> Fix getTopDn() to return root DN if no topDn is currently defined -> Create dedicated functions to support recoveryPassword mecanism : - recoverPasswd() - recoverPasswdSendMail() - recoverPasswdFirstStep() - recoverPasswdSecondStep -> Customize LSdebug return and display (php+js) -> Clean unused error codes -> Move LSrelation error codes -> Comment ajax method
2009-10-30 01:03:17 +01:00
/**
* Do first step of recovering password
2020-04-29 15:54:21 +02:00
*
* @param LSldapObject $user The LSldapObject of the user
2020-04-29 15:54:21 +02:00
*
* @return string|false The recory hash on success or False
- LSsearch/LSsearchEntry : Added a new classes to doing and exploit ldap object search -> view/select => change to use it (php+template+js) -> LSattr_html_select_object/LSattr_html_select_list => change to use it -> LSldapObject : -> change listObjectsName() / searchObject() / getSelectArray() / listObjects() -> comment search() function -> Add triggers to clean cache -> LSpeople : Update search config -> LSsession : Change function to use it : - getSubDnLdapServer() - loadLSprofiles() - LSrelation : Deplace error codes declaration from LSsession in class file - LSldapObject : -> change getObjectFilter() / getLabel() / getSubDnValue() / getSubDnName() for can call then staticaly -> Add afterModify() function and trigger -> Change getObjectFilter() / listObjectsInRelation() to use Net_LDAP2_Filter -> Add __get() function -> Move one LSerror code for LSrelation function from LSsession class file -> Add a global variable to save cached data ($cache) -> Change subDn and subDnName access methods - LSauth : Move LSsession auth procedure in a dedicated class -> LSsession : Change startLSsession() to use it - LSsession : -> Add getRootDn() function -> Fix getTopDn() to return root DN if no topDn is currently defined -> Create dedicated functions to support recoveryPassword mecanism : - recoverPasswd() - recoverPasswdSendMail() - recoverPasswdFirstStep() - recoverPasswdSecondStep -> Customize LSdebug return and display (php+js) -> Clean unused error codes -> Move LSrelation error codes -> Comment ajax method
2009-10-30 01:03:17 +01:00
**/
private static function recoverPasswdFirstStep($user) {
// Generer un hash
$rdn=$user -> getValue('rdn');
$rdn = $rdn[0];
$recovery_hash = md5($rdn . strval(time()) . strval(rand()));
2020-04-29 15:54:21 +02:00
- LSsearch/LSsearchEntry : Added a new classes to doing and exploit ldap object search -> view/select => change to use it (php+template+js) -> LSattr_html_select_object/LSattr_html_select_list => change to use it -> LSldapObject : -> change listObjectsName() / searchObject() / getSelectArray() / listObjects() -> comment search() function -> Add triggers to clean cache -> LSpeople : Update search config -> LSsession : Change function to use it : - getSubDnLdapServer() - loadLSprofiles() - LSrelation : Deplace error codes declaration from LSsession in class file - LSldapObject : -> change getObjectFilter() / getLabel() / getSubDnValue() / getSubDnName() for can call then staticaly -> Add afterModify() function and trigger -> Change getObjectFilter() / listObjectsInRelation() to use Net_LDAP2_Filter -> Add __get() function -> Move one LSerror code for LSrelation function from LSsession class file -> Add a global variable to save cached data ($cache) -> Change subDn and subDnName access methods - LSauth : Move LSsession auth procedure in a dedicated class -> LSsession : Change startLSsession() to use it - LSsession : -> Add getRootDn() function -> Fix getTopDn() to return root DN if no topDn is currently defined -> Create dedicated functions to support recoveryPassword mecanism : - recoverPasswd() - recoverPasswdSendMail() - recoverPasswdFirstStep() - recoverPasswdSecondStep -> Customize LSdebug return and display (php+js) -> Clean unused error codes -> Move LSrelation error codes -> Comment ajax method
2009-10-30 01:03:17 +01:00
$lostPasswdForm = $user -> getForm('lostPassword');
$lostPasswdForm -> setPostData(
array(
self :: $ldapServer['recoverPassword']['recoveryHashAttr'] => $recovery_hash
)
,true
);
2020-04-29 15:54:21 +02:00
- LSsearch/LSsearchEntry : Added a new classes to doing and exploit ldap object search -> view/select => change to use it (php+template+js) -> LSattr_html_select_object/LSattr_html_select_list => change to use it -> LSldapObject : -> change listObjectsName() / searchObject() / getSelectArray() / listObjects() -> comment search() function -> Add triggers to clean cache -> LSpeople : Update search config -> LSsession : Change function to use it : - getSubDnLdapServer() - loadLSprofiles() - LSrelation : Deplace error codes declaration from LSsession in class file - LSldapObject : -> change getObjectFilter() / getLabel() / getSubDnValue() / getSubDnName() for can call then staticaly -> Add afterModify() function and trigger -> Change getObjectFilter() / listObjectsInRelation() to use Net_LDAP2_Filter -> Add __get() function -> Move one LSerror code for LSrelation function from LSsession class file -> Add a global variable to save cached data ($cache) -> Change subDn and subDnName access methods - LSauth : Move LSsession auth procedure in a dedicated class -> LSsession : Change startLSsession() to use it - LSsession : -> Add getRootDn() function -> Fix getTopDn() to return root DN if no topDn is currently defined -> Create dedicated functions to support recoveryPassword mecanism : - recoverPasswd() - recoverPasswdSendMail() - recoverPasswdFirstStep() - recoverPasswdSecondStep -> Customize LSdebug return and display (php+js) -> Clean unused error codes -> Move LSrelation error codes -> Comment ajax method
2009-10-30 01:03:17 +01:00
if($lostPasswdForm -> validate()) {
if ($user -> updateData('lostPassword')) {
// recoveryHash de l'utilisateur mis à jour
return $recovery_hash;
}
else {
// Erreur durant la mise à jour de l'objet
2020-05-08 15:51:21 +02:00
self :: log_error("recoverPasswdFirstStep($user): error updating user.");
- LSsearch/LSsearchEntry : Added a new classes to doing and exploit ldap object search -> view/select => change to use it (php+template+js) -> LSattr_html_select_object/LSattr_html_select_list => change to use it -> LSldapObject : -> change listObjectsName() / searchObject() / getSelectArray() / listObjects() -> comment search() function -> Add triggers to clean cache -> LSpeople : Update search config -> LSsession : Change function to use it : - getSubDnLdapServer() - loadLSprofiles() - LSrelation : Deplace error codes declaration from LSsession in class file - LSldapObject : -> change getObjectFilter() / getLabel() / getSubDnValue() / getSubDnName() for can call then staticaly -> Add afterModify() function and trigger -> Change getObjectFilter() / listObjectsInRelation() to use Net_LDAP2_Filter -> Add __get() function -> Move one LSerror code for LSrelation function from LSsession class file -> Add a global variable to save cached data ($cache) -> Change subDn and subDnName access methods - LSauth : Move LSsession auth procedure in a dedicated class -> LSsession : Change startLSsession() to use it - LSsession : -> Add getRootDn() function -> Fix getTopDn() to return root DN if no topDn is currently defined -> Create dedicated functions to support recoveryPassword mecanism : - recoverPasswd() - recoverPasswdSendMail() - recoverPasswdFirstStep() - recoverPasswdSecondStep -> Customize LSdebug return and display (php+js) -> Clean unused error codes -> Move LSrelation error codes -> Comment ajax method
2009-10-30 01:03:17 +01:00
LSerror :: addErrorCode('LSsession_20',6);
}
}
else {
// Erreur durant la validation du formulaire de modification de perte de password
2020-05-08 15:51:21 +02:00
self :: log_error("recoverPasswdFirstStep($user): error validating form.");
- LSsearch/LSsearchEntry : Added a new classes to doing and exploit ldap object search -> view/select => change to use it (php+template+js) -> LSattr_html_select_object/LSattr_html_select_list => change to use it -> LSldapObject : -> change listObjectsName() / searchObject() / getSelectArray() / listObjects() -> comment search() function -> Add triggers to clean cache -> LSpeople : Update search config -> LSsession : Change function to use it : - getSubDnLdapServer() - loadLSprofiles() - LSrelation : Deplace error codes declaration from LSsession in class file - LSldapObject : -> change getObjectFilter() / getLabel() / getSubDnValue() / getSubDnName() for can call then staticaly -> Add afterModify() function and trigger -> Change getObjectFilter() / listObjectsInRelation() to use Net_LDAP2_Filter -> Add __get() function -> Move one LSerror code for LSrelation function from LSsession class file -> Add a global variable to save cached data ($cache) -> Change subDn and subDnName access methods - LSauth : Move LSsession auth procedure in a dedicated class -> LSsession : Change startLSsession() to use it - LSsession : -> Add getRootDn() function -> Fix getTopDn() to return root DN if no topDn is currently defined -> Create dedicated functions to support recoveryPassword mecanism : - recoverPasswd() - recoverPasswdSendMail() - recoverPasswdFirstStep() - recoverPasswdSecondStep -> Customize LSdebug return and display (php+js) -> Clean unused error codes -> Move LSrelation error codes -> Comment ajax method
2009-10-30 01:03:17 +01:00
LSerror :: addErrorCode('LSsession_20',5);
}
return false;
- LSsearch/LSsearchEntry : Added a new classes to doing and exploit ldap object search -> view/select => change to use it (php+template+js) -> LSattr_html_select_object/LSattr_html_select_list => change to use it -> LSldapObject : -> change listObjectsName() / searchObject() / getSelectArray() / listObjects() -> comment search() function -> Add triggers to clean cache -> LSpeople : Update search config -> LSsession : Change function to use it : - getSubDnLdapServer() - loadLSprofiles() - LSrelation : Deplace error codes declaration from LSsession in class file - LSldapObject : -> change getObjectFilter() / getLabel() / getSubDnValue() / getSubDnName() for can call then staticaly -> Add afterModify() function and trigger -> Change getObjectFilter() / listObjectsInRelation() to use Net_LDAP2_Filter -> Add __get() function -> Move one LSerror code for LSrelation function from LSsession class file -> Add a global variable to save cached data ($cache) -> Change subDn and subDnName access methods - LSauth : Move LSsession auth procedure in a dedicated class -> LSsession : Change startLSsession() to use it - LSsession : -> Add getRootDn() function -> Fix getTopDn() to return root DN if no topDn is currently defined -> Create dedicated functions to support recoveryPassword mecanism : - recoverPasswd() - recoverPasswdSendMail() - recoverPasswdFirstStep() - recoverPasswdSecondStep -> Customize LSdebug return and display (php+js) -> Clean unused error codes -> Move LSrelation error codes -> Comment ajax method
2009-10-30 01:03:17 +01:00
}
/**
* Do second step of recovering password
2020-04-29 15:54:21 +02:00
*
* @param LSldapObject $user The LSldapObject of the user
2020-04-29 15:54:21 +02:00
*
* @return string|false The new password on success or False
- LSsearch/LSsearchEntry : Added a new classes to doing and exploit ldap object search -> view/select => change to use it (php+template+js) -> LSattr_html_select_object/LSattr_html_select_list => change to use it -> LSldapObject : -> change listObjectsName() / searchObject() / getSelectArray() / listObjects() -> comment search() function -> Add triggers to clean cache -> LSpeople : Update search config -> LSsession : Change function to use it : - getSubDnLdapServer() - loadLSprofiles() - LSrelation : Deplace error codes declaration from LSsession in class file - LSldapObject : -> change getObjectFilter() / getLabel() / getSubDnValue() / getSubDnName() for can call then staticaly -> Add afterModify() function and trigger -> Change getObjectFilter() / listObjectsInRelation() to use Net_LDAP2_Filter -> Add __get() function -> Move one LSerror code for LSrelation function from LSsession class file -> Add a global variable to save cached data ($cache) -> Change subDn and subDnName access methods - LSauth : Move LSsession auth procedure in a dedicated class -> LSsession : Change startLSsession() to use it - LSsession : -> Add getRootDn() function -> Fix getTopDn() to return root DN if no topDn is currently defined -> Create dedicated functions to support recoveryPassword mecanism : - recoverPasswd() - recoverPasswdSendMail() - recoverPasswdFirstStep() - recoverPasswdSecondStep -> Customize LSdebug return and display (php+js) -> Clean unused error codes -> Move LSrelation error codes -> Comment ajax method
2009-10-30 01:03:17 +01:00
**/
private static function recoverPasswdSecondStep($user) {
$pwd_attr_name = LSauth :: getUserPasswordAttribute($user);
if (array_key_exists($pwd_attr_name, $user -> attrs)) {
$pwd_attr = $user -> attrs[$pwd_attr_name];
$pwd = generatePassword(
$pwd_attr -> getConfig('html_options.chars'),
2020-05-12 20:20:11 +02:00
$pwd_attr -> getConfig('html_options.lenght')
- LSsearch/LSsearchEntry : Added a new classes to doing and exploit ldap object search -> view/select => change to use it (php+template+js) -> LSattr_html_select_object/LSattr_html_select_list => change to use it -> LSldapObject : -> change listObjectsName() / searchObject() / getSelectArray() / listObjects() -> comment search() function -> Add triggers to clean cache -> LSpeople : Update search config -> LSsession : Change function to use it : - getSubDnLdapServer() - loadLSprofiles() - LSrelation : Deplace error codes declaration from LSsession in class file - LSldapObject : -> change getObjectFilter() / getLabel() / getSubDnValue() / getSubDnName() for can call then staticaly -> Add afterModify() function and trigger -> Change getObjectFilter() / listObjectsInRelation() to use Net_LDAP2_Filter -> Add __get() function -> Move one LSerror code for LSrelation function from LSsession class file -> Add a global variable to save cached data ($cache) -> Change subDn and subDnName access methods - LSauth : Move LSsession auth procedure in a dedicated class -> LSsession : Change startLSsession() to use it - LSsession : -> Add getRootDn() function -> Fix getTopDn() to return root DN if no topDn is currently defined -> Create dedicated functions to support recoveryPassword mecanism : - recoverPasswd() - recoverPasswdSendMail() - recoverPasswdFirstStep() - recoverPasswdSecondStep -> Customize LSdebug return and display (php+js) -> Clean unused error codes -> Move LSrelation error codes -> Comment ajax method
2009-10-30 01:03:17 +01:00
);
self :: log_debug("recoverPasswdSecondStep($user): new password = '$pwd'.");
- LSsearch/LSsearchEntry : Added a new classes to doing and exploit ldap object search -> view/select => change to use it (php+template+js) -> LSattr_html_select_object/LSattr_html_select_list => change to use it -> LSldapObject : -> change listObjectsName() / searchObject() / getSelectArray() / listObjects() -> comment search() function -> Add triggers to clean cache -> LSpeople : Update search config -> LSsession : Change function to use it : - getSubDnLdapServer() - loadLSprofiles() - LSrelation : Deplace error codes declaration from LSsession in class file - LSldapObject : -> change getObjectFilter() / getLabel() / getSubDnValue() / getSubDnName() for can call then staticaly -> Add afterModify() function and trigger -> Change getObjectFilter() / listObjectsInRelation() to use Net_LDAP2_Filter -> Add __get() function -> Move one LSerror code for LSrelation function from LSsession class file -> Add a global variable to save cached data ($cache) -> Change subDn and subDnName access methods - LSauth : Move LSsession auth procedure in a dedicated class -> LSsession : Change startLSsession() to use it - LSsession : -> Add getRootDn() function -> Fix getTopDn() to return root DN if no topDn is currently defined -> Create dedicated functions to support recoveryPassword mecanism : - recoverPasswd() - recoverPasswdSendMail() - recoverPasswdFirstStep() - recoverPasswdSecondStep -> Customize LSdebug return and display (php+js) -> Clean unused error codes -> Move LSrelation error codes -> Comment ajax method
2009-10-30 01:03:17 +01:00
$lostPasswdForm = $user -> getForm('lostPassword');
$lostPasswdForm -> setPostData(
array(
self :: $ldapServer['recoverPassword']['recoveryHashAttr'] => array(''),
$pwd_attr_name => array($pwd)
- LSsearch/LSsearchEntry : Added a new classes to doing and exploit ldap object search -> view/select => change to use it (php+template+js) -> LSattr_html_select_object/LSattr_html_select_list => change to use it -> LSldapObject : -> change listObjectsName() / searchObject() / getSelectArray() / listObjects() -> comment search() function -> Add triggers to clean cache -> LSpeople : Update search config -> LSsession : Change function to use it : - getSubDnLdapServer() - loadLSprofiles() - LSrelation : Deplace error codes declaration from LSsession in class file - LSldapObject : -> change getObjectFilter() / getLabel() / getSubDnValue() / getSubDnName() for can call then staticaly -> Add afterModify() function and trigger -> Change getObjectFilter() / listObjectsInRelation() to use Net_LDAP2_Filter -> Add __get() function -> Move one LSerror code for LSrelation function from LSsession class file -> Add a global variable to save cached data ($cache) -> Change subDn and subDnName access methods - LSauth : Move LSsession auth procedure in a dedicated class -> LSsession : Change startLSsession() to use it - LSsession : -> Add getRootDn() function -> Fix getTopDn() to return root DN if no topDn is currently defined -> Create dedicated functions to support recoveryPassword mecanism : - recoverPasswd() - recoverPasswdSendMail() - recoverPasswdFirstStep() - recoverPasswdSecondStep -> Customize LSdebug return and display (php+js) -> Clean unused error codes -> Move LSrelation error codes -> Comment ajax method
2009-10-30 01:03:17 +01:00
)
,true
);
if($lostPasswdForm -> validate()) {
if ($user -> updateData('lostPassword')) {
return $pwd;
- LSsearch/LSsearchEntry : Added a new classes to doing and exploit ldap object search -> view/select => change to use it (php+template+js) -> LSattr_html_select_object/LSattr_html_select_list => change to use it -> LSldapObject : -> change listObjectsName() / searchObject() / getSelectArray() / listObjects() -> comment search() function -> Add triggers to clean cache -> LSpeople : Update search config -> LSsession : Change function to use it : - getSubDnLdapServer() - loadLSprofiles() - LSrelation : Deplace error codes declaration from LSsession in class file - LSldapObject : -> change getObjectFilter() / getLabel() / getSubDnValue() / getSubDnName() for can call then staticaly -> Add afterModify() function and trigger -> Change getObjectFilter() / listObjectsInRelation() to use Net_LDAP2_Filter -> Add __get() function -> Move one LSerror code for LSrelation function from LSsession class file -> Add a global variable to save cached data ($cache) -> Change subDn and subDnName access methods - LSauth : Move LSsession auth procedure in a dedicated class -> LSsession : Change startLSsession() to use it - LSsession : -> Add getRootDn() function -> Fix getTopDn() to return root DN if no topDn is currently defined -> Create dedicated functions to support recoveryPassword mecanism : - recoverPasswd() - recoverPasswdSendMail() - recoverPasswdFirstStep() - recoverPasswdSecondStep -> Customize LSdebug return and display (php+js) -> Clean unused error codes -> Move LSrelation error codes -> Comment ajax method
2009-10-30 01:03:17 +01:00
}
else {
// Erreur durant la mise à jour de l'objet
2020-05-08 15:51:21 +02:00
self :: log_error("recoverPasswdSecondStep($user): error updating user.");
- LSsearch/LSsearchEntry : Added a new classes to doing and exploit ldap object search -> view/select => change to use it (php+template+js) -> LSattr_html_select_object/LSattr_html_select_list => change to use it -> LSldapObject : -> change listObjectsName() / searchObject() / getSelectArray() / listObjects() -> comment search() function -> Add triggers to clean cache -> LSpeople : Update search config -> LSsession : Change function to use it : - getSubDnLdapServer() - loadLSprofiles() - LSrelation : Deplace error codes declaration from LSsession in class file - LSldapObject : -> change getObjectFilter() / getLabel() / getSubDnValue() / getSubDnName() for can call then staticaly -> Add afterModify() function and trigger -> Change getObjectFilter() / listObjectsInRelation() to use Net_LDAP2_Filter -> Add __get() function -> Move one LSerror code for LSrelation function from LSsession class file -> Add a global variable to save cached data ($cache) -> Change subDn and subDnName access methods - LSauth : Move LSsession auth procedure in a dedicated class -> LSsession : Change startLSsession() to use it - LSsession : -> Add getRootDn() function -> Fix getTopDn() to return root DN if no topDn is currently defined -> Create dedicated functions to support recoveryPassword mecanism : - recoverPasswd() - recoverPasswdSendMail() - recoverPasswdFirstStep() - recoverPasswdSecondStep -> Customize LSdebug return and display (php+js) -> Clean unused error codes -> Move LSrelation error codes -> Comment ajax method
2009-10-30 01:03:17 +01:00
LSerror :: addErrorCode('LSsession_20',3);
}
}
else {
// Erreur durant la validation du formulaire de modification de perte de password
2020-05-08 15:51:21 +02:00
self :: log_error("recoverPasswdSecondStep($user): error validating form.");
- LSsearch/LSsearchEntry : Added a new classes to doing and exploit ldap object search -> view/select => change to use it (php+template+js) -> LSattr_html_select_object/LSattr_html_select_list => change to use it -> LSldapObject : -> change listObjectsName() / searchObject() / getSelectArray() / listObjects() -> comment search() function -> Add triggers to clean cache -> LSpeople : Update search config -> LSsession : Change function to use it : - getSubDnLdapServer() - loadLSprofiles() - LSrelation : Deplace error codes declaration from LSsession in class file - LSldapObject : -> change getObjectFilter() / getLabel() / getSubDnValue() / getSubDnName() for can call then staticaly -> Add afterModify() function and trigger -> Change getObjectFilter() / listObjectsInRelation() to use Net_LDAP2_Filter -> Add __get() function -> Move one LSerror code for LSrelation function from LSsession class file -> Add a global variable to save cached data ($cache) -> Change subDn and subDnName access methods - LSauth : Move LSsession auth procedure in a dedicated class -> LSsession : Change startLSsession() to use it - LSsession : -> Add getRootDn() function -> Fix getTopDn() to return root DN if no topDn is currently defined -> Create dedicated functions to support recoveryPassword mecanism : - recoverPasswd() - recoverPasswdSendMail() - recoverPasswdFirstStep() - recoverPasswdSecondStep -> Customize LSdebug return and display (php+js) -> Clean unused error codes -> Move LSrelation error codes -> Comment ajax method
2009-10-30 01:03:17 +01:00
LSerror :: addErrorCode('LSsession_20',2);
}
}
else {
// l'attribut password n'existe pas
self :: log_error("recoverPasswdSecondStep($user): password attribute '$pwd_attr_name' does not exists.");
- LSsearch/LSsearchEntry : Added a new classes to doing and exploit ldap object search -> view/select => change to use it (php+template+js) -> LSattr_html_select_object/LSattr_html_select_list => change to use it -> LSldapObject : -> change listObjectsName() / searchObject() / getSelectArray() / listObjects() -> comment search() function -> Add triggers to clean cache -> LSpeople : Update search config -> LSsession : Change function to use it : - getSubDnLdapServer() - loadLSprofiles() - LSrelation : Deplace error codes declaration from LSsession in class file - LSldapObject : -> change getObjectFilter() / getLabel() / getSubDnValue() / getSubDnName() for can call then staticaly -> Add afterModify() function and trigger -> Change getObjectFilter() / listObjectsInRelation() to use Net_LDAP2_Filter -> Add __get() function -> Move one LSerror code for LSrelation function from LSsession class file -> Add a global variable to save cached data ($cache) -> Change subDn and subDnName access methods - LSauth : Move LSsession auth procedure in a dedicated class -> LSsession : Change startLSsession() to use it - LSsession : -> Add getRootDn() function -> Fix getTopDn() to return root DN if no topDn is currently defined -> Create dedicated functions to support recoveryPassword mecanism : - recoverPasswd() - recoverPasswdSendMail() - recoverPasswdFirstStep() - recoverPasswdSecondStep -> Customize LSdebug return and display (php+js) -> Clean unused error codes -> Move LSrelation error codes -> Comment ajax method
2009-10-30 01:03:17 +01:00
LSerror :: addErrorCode('LSsession_20',1);
}
return false;
- LSsearch/LSsearchEntry : Added a new classes to doing and exploit ldap object search -> view/select => change to use it (php+template+js) -> LSattr_html_select_object/LSattr_html_select_list => change to use it -> LSldapObject : -> change listObjectsName() / searchObject() / getSelectArray() / listObjects() -> comment search() function -> Add triggers to clean cache -> LSpeople : Update search config -> LSsession : Change function to use it : - getSubDnLdapServer() - loadLSprofiles() - LSrelation : Deplace error codes declaration from LSsession in class file - LSldapObject : -> change getObjectFilter() / getLabel() / getSubDnValue() / getSubDnName() for can call then staticaly -> Add afterModify() function and trigger -> Change getObjectFilter() / listObjectsInRelation() to use Net_LDAP2_Filter -> Add __get() function -> Move one LSerror code for LSrelation function from LSsession class file -> Add a global variable to save cached data ($cache) -> Change subDn and subDnName access methods - LSauth : Move LSsession auth procedure in a dedicated class -> LSsession : Change startLSsession() to use it - LSsession : -> Add getRootDn() function -> Fix getTopDn() to return root DN if no topDn is currently defined -> Create dedicated functions to support recoveryPassword mecanism : - recoverPasswd() - recoverPasswdSendMail() - recoverPasswdFirstStep() - recoverPasswdSecondStep -> Customize LSdebug return and display (php+js) -> Clean unused error codes -> Move LSrelation error codes -> Comment ajax method
2009-10-30 01:03:17 +01:00
}
2020-04-29 15:54:21 +02:00
/**
2021-08-25 18:02:37 +02:00
* Retrieve context information (to store in PHP session)
*
* @author Benjamin Renard <brenard@easter-eggs.com
2020-04-29 15:54:21 +02:00
*
* @return array Associative array of context information
*/
private static function getContextInfos() {
return array(
'tmp_file' => self :: $tmp_file,
'topDn' => self :: $topDn,
'dn' => self :: $dn,
'rdn' => self :: $rdn,
'LSuserObjectType' => self :: $LSuserObjectType,
'userLDAPcreds' => self :: $userLDAPcreds,
'ldapServerId' => self :: $ldapServerId,
'ldapServer' => self :: $ldapServer,
'LSprofiles' => self :: $LSprofiles,
2015-08-21 17:51:52 +02:00
'LSaccess' => self :: $LSaccess,
'LSaddonsViewsAccess' => self :: $LSaddonsViewsAccess
);
}
2020-04-29 15:54:21 +02:00
/**
* Save context information in PHP session
*
* @author Benjamin Renard <brenard@easter-eggs.com
*
* @return void
*/
private static function saveContextInfos() {
$_SESSION['LSsession'] = (
isset($_SESSION['LSsession']) && is_array($_SESSION['LSsession'])?
array_merge($_SESSION['LSsession'], self :: getContextInfos()):
self :: getContextInfos()
);
}
/**
2021-08-25 18:02:37 +02:00
* Retrieve connected user LSobject (as reference)
*
* @author Benjamin Renard <brenard@easter-eggs.com
2020-04-29 15:54:21 +02:00
*
* @return LSldapObject|false Current connected user LSldapObject, or False in case of error
*/
public static function &getLSuserObject($dn=null) {
if ($dn) {
self :: $dn = $dn;
}
if (!self :: $LSuserObject) {
if (self :: $LSuserObjectType && self :: loadLSobject(self :: $LSuserObjectType)) {
self :: $LSuserObject = new self :: $LSuserObjectType();
if (!self :: $LSuserObject -> loadData(self :: $dn)) {
self :: $LSuserObject = null;
2021-08-25 18:02:37 +02:00
self :: log_error(
"getLSuserObject($dn): Fail to retrieve current connected user ".
"information from LDAP"
);
return false;
}
}
else {
2021-08-25 18:02:37 +02:00
self :: log_error(
"getLSuserObject($dn): Current connected user object type not ".
"defined or can not be loaded (".self :: $LSuserObjectType.")"
);
return false;
}
}
return self :: $LSuserObject;
}
2020-04-29 15:54:21 +02:00
2020-05-07 12:16:12 +02:00
/**
* Check if user is connected
*
* @author Benjamin Renard <brenard@easter-eggs.com
*
* @return boolean True if user connected, false instead
2020-05-07 12:16:12 +02:00
*/
public static function isConnected() {
if (self :: getLSuserObject())
2020-05-07 12:16:12 +02:00
return true;
return false;
}
/**
* Retourne le DN de l'utilisateur connecté
*
* @author Benjamin Renard <brenard@easter-eggs.com
2020-04-29 15:54:21 +02:00
*
* @return string Le DN de l'utilisateur connecté
*/
public static function getLSuserObjectDn() {
return self :: $dn;
}
- LSldapObject : -> Ajout de la possibilité de changer le RDN d'un objet -> Mise à jour automatique des relations définis avec les autres types d'objet à partir du moment que le paramètre 'rename_function' est défini dans la configuration de la relation -> Ajout des méthodes suivantes : -> beforeRename() : Executer avant le changement de DN elle permet de préparer le renomage. -> afterRename() : Executer après le changement de DN elle finalise le renomage. -> Méthode submitData() : prise en charge du changement du RDN - LSrelation : -> Correction d'une erreur dans index_ajax.php : le paramètre $relationConf['remove_function'] n'était pas utilisé - LSeegroup : -> Création d'une propriété $userObjectType pour stocké le type des objets utilisateurs -> Création de la méthode renameOneMember() pour assurer les modifications nécéssaire lors du changement de DN d'un utilisateur - LSformElement_date : Suppression du chargement du fichier js : calendar-setup inutile l'utilisation faite de jscalendar. - LSattribute : -> Ajout d'une possibilité pour générer une valeur à partir d'un format de chaine et la méthode getFData() des objets LSldapObject. Cette méthode fait référence au paramètre 'generate_value_format' de la configuration d'un attribut pour générer la valeur - LSldap : -> Ajout d'une méthode move() pour changer le DN d'un objet - LSsession : -> Ajout de la méthode changeAuthUser() pour changer l'utilisateur connecté en cour de session. (Utile lors de la modification de l'utilisateur par lui même) - functions.php : Correction d'un bug dans la fontion getFData(). - modify.php : Vérification des droits de l'utilisateur après chargement et eventuellement modification de celui-ci pour intégrer les eventuelles modifications faites par l'utilisateur.
2008-07-29 15:45:02 +02:00
/**
* Live change of the connected user
2020-04-29 15:54:21 +02:00
*
* @param LSldapObject $object The new connected user object
2020-04-29 15:54:21 +02:00
*
* @return boolean True on success, false otherwise
- LSldapObject : -> Ajout de la possibilité de changer le RDN d'un objet -> Mise à jour automatique des relations définis avec les autres types d'objet à partir du moment que le paramètre 'rename_function' est défini dans la configuration de la relation -> Ajout des méthodes suivantes : -> beforeRename() : Executer avant le changement de DN elle permet de préparer le renomage. -> afterRename() : Executer après le changement de DN elle finalise le renomage. -> Méthode submitData() : prise en charge du changement du RDN - LSrelation : -> Correction d'une erreur dans index_ajax.php : le paramètre $relationConf['remove_function'] n'était pas utilisé - LSeegroup : -> Création d'une propriété $userObjectType pour stocké le type des objets utilisateurs -> Création de la méthode renameOneMember() pour assurer les modifications nécéssaire lors du changement de DN d'un utilisateur - LSformElement_date : Suppression du chargement du fichier js : calendar-setup inutile l'utilisation faite de jscalendar. - LSattribute : -> Ajout d'une possibilité pour générer une valeur à partir d'un format de chaine et la méthode getFData() des objets LSldapObject. Cette méthode fait référence au paramètre 'generate_value_format' de la configuration d'un attribut pour générer la valeur - LSldap : -> Ajout d'une méthode move() pour changer le DN d'un objet - LSsession : -> Ajout de la méthode changeAuthUser() pour changer l'utilisateur connecté en cour de session. (Utile lors de la modification de l'utilisateur par lui même) - functions.php : Correction d'un bug dans la fontion getFData(). - modify.php : Vérification des droits de l'utilisateur après chargement et eventuellement modification de celui-ci pour intégrer les eventuelles modifications faites par l'utilisateur.
2008-07-29 15:45:02 +02:00
*/
public static function changeAuthUser($object) {
if(!($object instanceof LSldapObject)) {
2021-08-25 18:02:37 +02:00
self :: log_error(
"changeAuthUser(): An LSldapObject must be provided, not ".get_class($object)
);
return false;
}
if(!array_key_exists($object -> getType(), LSauth :: getAuthObjectTypes())) {
self :: log_error(
"changeAuthUser(): Invalid object provided, must be one of following types (not a ".
$object -> getType().') : '.implode(', ', array_keys(LSauth :: getAuthObjectTypes()))
);
return false;
}
2021-08-25 18:02:37 +02:00
self :: log_info(
"Change authenticated user info ('".self :: $dn."' -> '".$object -> getDn()."')"
);
self :: $dn = $object -> getDn();
$rdn = $object -> getValue('rdn');
if(is_array($rdn)) {
$rdn = $rdn[0];
}
self :: $rdn = $rdn;
self :: $LSuserObject = $object;
self :: $LSuserObjectType = $object -> getType();
if(self :: loadLSprofiles()) {
self :: loadLSaccess();
self :: loadLSaddonsViewsAccess();
self :: saveContextInfos();
self :: log_debug("changeAuthUser(): authenticated user successfully updated.");
return true;
- LSldapObject : -> Ajout de la possibilité de changer le RDN d'un objet -> Mise à jour automatique des relations définis avec les autres types d'objet à partir du moment que le paramètre 'rename_function' est défini dans la configuration de la relation -> Ajout des méthodes suivantes : -> beforeRename() : Executer avant le changement de DN elle permet de préparer le renomage. -> afterRename() : Executer après le changement de DN elle finalise le renomage. -> Méthode submitData() : prise en charge du changement du RDN - LSrelation : -> Correction d'une erreur dans index_ajax.php : le paramètre $relationConf['remove_function'] n'était pas utilisé - LSeegroup : -> Création d'une propriété $userObjectType pour stocké le type des objets utilisateurs -> Création de la méthode renameOneMember() pour assurer les modifications nécéssaire lors du changement de DN d'un utilisateur - LSformElement_date : Suppression du chargement du fichier js : calendar-setup inutile l'utilisation faite de jscalendar. - LSattribute : -> Ajout d'une possibilité pour générer une valeur à partir d'un format de chaine et la méthode getFData() des objets LSldapObject. Cette méthode fait référence au paramètre 'generate_value_format' de la configuration d'un attribut pour générer la valeur - LSldap : -> Ajout d'une méthode move() pour changer le DN d'un objet - LSsession : -> Ajout de la méthode changeAuthUser() pour changer l'utilisateur connecté en cour de session. (Utile lors de la modification de l'utilisateur par lui même) - functions.php : Correction d'un bug dans la fontion getFData(). - modify.php : Vérification des droits de l'utilisateur après chargement et eventuellement modification de celui-ci pour intégrer les eventuelles modifications faites par l'utilisateur.
2008-07-29 15:45:02 +02:00
}
self :: log_error("Fail to reload LSprofiles after updating auth user info.");
return false;
- LSldapObject : -> Ajout de la possibilité de changer le RDN d'un objet -> Mise à jour automatique des relations définis avec les autres types d'objet à partir du moment que le paramètre 'rename_function' est défini dans la configuration de la relation -> Ajout des méthodes suivantes : -> beforeRename() : Executer avant le changement de DN elle permet de préparer le renomage. -> afterRename() : Executer après le changement de DN elle finalise le renomage. -> Méthode submitData() : prise en charge du changement du RDN - LSrelation : -> Correction d'une erreur dans index_ajax.php : le paramètre $relationConf['remove_function'] n'était pas utilisé - LSeegroup : -> Création d'une propriété $userObjectType pour stocké le type des objets utilisateurs -> Création de la méthode renameOneMember() pour assurer les modifications nécéssaire lors du changement de DN d'un utilisateur - LSformElement_date : Suppression du chargement du fichier js : calendar-setup inutile l'utilisation faite de jscalendar. - LSattribute : -> Ajout d'une possibilité pour générer une valeur à partir d'un format de chaine et la méthode getFData() des objets LSldapObject. Cette méthode fait référence au paramètre 'generate_value_format' de la configuration d'un attribut pour générer la valeur - LSldap : -> Ajout d'une méthode move() pour changer le DN d'un objet - LSsession : -> Ajout de la méthode changeAuthUser() pour changer l'utilisateur connecté en cour de session. (Utile lors de la modification de l'utilisateur par lui même) - functions.php : Correction d'un bug dans la fontion getFData(). - modify.php : Vérification des droits de l'utilisateur après chargement et eventuellement modification de celui-ci pour intégrer les eventuelles modifications faites par l'utilisateur.
2008-07-29 15:45:02 +02:00
}
/**
2020-08-06 16:43:35 +02:00
* Set the LDAP server of the session
*
2020-08-06 16:43:35 +02:00
* Set the LDAP server of the session from its ID in configuration array
* LSconfig :: get('ldap_servers').
*
* @param int $id Index of LDAP server
* @param string|null $subDn SubDN of LDAP server (optional)
*
* @return boolean True if set, false otherwise
*/
2020-08-06 16:43:35 +02:00
public static function setLdapServer($id, $subDn=null) {
$conf = LSconfig :: get("ldap_servers.$id");
if ( is_array($conf) ) {
self :: $ldapServerId = $id;
self :: $ldapServer = $conf;
LSlang :: setLocale();
self :: setGlobals();
2020-08-06 16:43:35 +02:00
if ($subDn)
return self :: setSubDn($subDn);
return true;
}
2020-08-06 16:43:35 +02:00
return false;
}
/**
* Set the subDn of the session
*
* @param string $subDn SubDN of LDAP server
2020-08-06 16:43:35 +02:00
*
* @return boolean True if set, false otherwise
2020-08-06 16:43:35 +02:00
*/
public static function setSubDn($subDn) {
if (self :: validSubDnLdapServer($subDn)) {
self :: $topDn = $subDn;
$_SESSION['LSsession']['topDn'] = $subDn;
return true;
}
return false;
}
/**
* Connexion au serveur Ldap
*
* @return boolean True sinon false.
*/
public static function LSldapConnect() {
if (!self :: $ldapServer && !self :: setLdapServer(0)) {
return false;
}
if (!self :: $ldapServer) {
LSerror :: addErrorCode('LSsession_03');
return false;
}
self :: includeFile(LSconfig :: get('NetLDAP2'), true);
if (!self :: loadLSclass('LSldap')) {
return false;
}
if (
self :: $dn && isset(self :: $ldapServer['useUserCredentials']) &&
self :: $ldapServer['useUserCredentials']
) {
2021-08-25 18:02:37 +02:00
if (
isset(self :: $ldapServer['useAuthzProxyControl']) &&
self :: $ldapServer['useAuthzProxyControl']
2021-08-25 18:02:37 +02:00
) {
// Firstly connect using main config and after, set authz proxy control
if (
!LSldap :: connect(self :: $ldapServer['ldap_config']) ||
!LSldap :: setAuthzProxyControl(self :: $dn)
) {
LSerror :: addErrorCode('LSsession_15');
return false;
}
}
else {
LSldap :: reconnectAs(
self :: $userLDAPcreds['dn'],
self :: $userLDAPcreds['pwd'],
self :: $ldapServer['ldap_config']
);
}
}
else {
LSldap :: connect(self :: $ldapServer['ldap_config']);
}
return LSldap :: isConnected();
}
/**
* Use this function to know if subDn is enabled for the curent LdapServer
2020-04-29 15:54:21 +02:00
*
* @return boolean
**/
public static function subDnIsEnabled() {
if (!isset(self :: $ldapServer['subDn'])) {
return false;
}
if ( !is_array(self :: $ldapServer['subDn']) ) {
return false;
}
return true;
}
/**
* Retourne les sous-dns du serveur Ldap courant
*
* @return mixed Tableau des subDn, false si une erreur est survenue.
*/
public static function getSubDnLdapServer($login=false) {
$login=(bool)$login;
2021-08-25 18:02:37 +02:00
if (
self :: cacheSudDn() &&
isset(self :: $_subDnLdapServer[self :: $ldapServerId][$login])
) {
return self :: $_subDnLdapServer[self :: $ldapServerId][$login];
}
if (!self::subDnIsEnabled()) {
- LdapSaisie : J'ai commencé à écrire la docummentation de LdapSaisie que j'espère pour voir bientôt ajouté au SVN. Cela me fait mettre le doit sur quelques problèmes de nommages, d'organisation que j'ai corrigé sur le fait : - Concepte de level était enfaite celui de subDn : seule le nom subDn doit rester. - Le concept de LSrights dans LSsession et config.inc.php était mal nommé. Il correspond plus à la définition de LSprofile en réalité. Je l'ai renommé ainsi. - Les paramètres authobject et authobject_pwdattr n'étaient pas très représentatif. Je les ai renommé en authObjectType et authObjectTypeAttrPwd. - Templates : -> Correction du template default dans le but de changer la couleur bleu dominante juger trop flashy :). Au passage j'ai dégagé l'image de fond de #main utilisé pour colorer le menu : cette méthode est moche et quitte a à faire du moche je préfère utiliser un vulgaire tableau que des bidouille de ce genre. -> Création d'un logo pour LdapSaisie qui vient remplacer le logo Easter-Eggs utilisé jusqu'alors. -> Ajout d'un favicon. - LSerror : -> J'ai déplacé les definitions de code d'erreur dans le contexte concerné (càd dans les fichiers de définition des classes) (Feature Request #1757) -> J'en ai profité pour renommer les codes d'erreur avec un prefixe pour eviter les doublons -> J'ai donc modifié une grande partie des fichiers pour changer les codes erreurs utilisés -> Ajout d'une méthode getError() utilisé par getErrors() -> Modification de la méthode stop() - LSformElement_password : - Correction d'un bug dans la génération des mots de passe dans un formulaire de création d'objet. - Ajout d'une possiblité de choisir le type de hashage du mot de passe stocké dans l'annuaire (Feature Request #1756) - Traduction des commentaires - LSattribute : Ajout des vérifications dans les méthodes de la classe lors de l'utilisation des objets html et ldap. - LSsession : -> Renforcement des méthodes faisant des inclusions d'autres fichiers php.
2009-01-02 17:00:25 +01:00
return;
}
$return=array();
foreach(self :: $ldapServer['subDn'] as $subDn_name => $subDn_config) {
2021-08-25 18:02:37 +02:00
if ($login && isset($subDn_config['nologin']) && $subDn_config['nologin'])
continue;
- LdapSaisie : J'ai commencé à écrire la docummentation de LdapSaisie que j'espère pour voir bientôt ajouté au SVN. Cela me fait mettre le doit sur quelques problèmes de nommages, d'organisation que j'ai corrigé sur le fait : - Concepte de level était enfaite celui de subDn : seule le nom subDn doit rester. - Le concept de LSrights dans LSsession et config.inc.php était mal nommé. Il correspond plus à la définition de LSprofile en réalité. Je l'ai renommé ainsi. - Les paramètres authobject et authobject_pwdattr n'étaient pas très représentatif. Je les ai renommé en authObjectType et authObjectTypeAttrPwd. - Templates : -> Correction du template default dans le but de changer la couleur bleu dominante juger trop flashy :). Au passage j'ai dégagé l'image de fond de #main utilisé pour colorer le menu : cette méthode est moche et quitte a à faire du moche je préfère utiliser un vulgaire tableau que des bidouille de ce genre. -> Création d'un logo pour LdapSaisie qui vient remplacer le logo Easter-Eggs utilisé jusqu'alors. -> Ajout d'un favicon. - LSerror : -> J'ai déplacé les definitions de code d'erreur dans le contexte concerné (càd dans les fichiers de définition des classes) (Feature Request #1757) -> J'en ai profité pour renommer les codes d'erreur avec un prefixe pour eviter les doublons -> J'ai donc modifié une grande partie des fichiers pour changer les codes erreurs utilisés -> Ajout d'une méthode getError() utilisé par getErrors() -> Modification de la méthode stop() - LSformElement_password : - Correction d'un bug dans la génération des mots de passe dans un formulaire de création d'objet. - Ajout d'une possiblité de choisir le type de hashage du mot de passe stocké dans l'annuaire (Feature Request #1756) - Traduction des commentaires - LSattribute : Ajout des vérifications dans les méthodes de la classe lors de l'utilisation des objets html et ldap. - LSsession : -> Renforcement des méthodes faisant des inclusions d'autres fichiers php.
2009-01-02 17:00:25 +01:00
if ($subDn_name == 'LSobject') {
if (is_array($subDn_config)) {
foreach($subDn_config as $LSobject_name => $LSoject_config) {
2021-08-25 18:02:37 +02:00
if (
isset($LSoject_config['basedn']) &&
!empty($LSoject_config['basedn'])
) {
$basedn = $LSoject_config['basedn'];
- LdapSaisie : J'ai commencé à écrire la docummentation de LdapSaisie que j'espère pour voir bientôt ajouté au SVN. Cela me fait mettre le doit sur quelques problèmes de nommages, d'organisation que j'ai corrigé sur le fait : - Concepte de level était enfaite celui de subDn : seule le nom subDn doit rester. - Le concept de LSrights dans LSsession et config.inc.php était mal nommé. Il correspond plus à la définition de LSprofile en réalité. Je l'ai renommé ainsi. - Les paramètres authobject et authobject_pwdattr n'étaient pas très représentatif. Je les ai renommé en authObjectType et authObjectTypeAttrPwd. - Templates : -> Correction du template default dans le but de changer la couleur bleu dominante juger trop flashy :). Au passage j'ai dégagé l'image de fond de #main utilisé pour colorer le menu : cette méthode est moche et quitte a à faire du moche je préfère utiliser un vulgaire tableau que des bidouille de ce genre. -> Création d'un logo pour LdapSaisie qui vient remplacer le logo Easter-Eggs utilisé jusqu'alors. -> Ajout d'un favicon. - LSerror : -> J'ai déplacé les definitions de code d'erreur dans le contexte concerné (càd dans les fichiers de définition des classes) (Feature Request #1757) -> J'en ai profité pour renommer les codes d'erreur avec un prefixe pour eviter les doublons -> J'ai donc modifié une grande partie des fichiers pour changer les codes erreurs utilisés -> Ajout d'une méthode getError() utilisé par getErrors() -> Modification de la méthode stop() - LSformElement_password : - Correction d'un bug dans la génération des mots de passe dans un formulaire de création d'objet. - Ajout d'une possiblité de choisir le type de hashage du mot de passe stocké dans l'annuaire (Feature Request #1756) - Traduction des commentaires - LSattribute : Ajout des vérifications dans les méthodes de la classe lors de l'utilisation des objets html et ldap. - LSsession : -> Renforcement des méthodes faisant des inclusions d'autres fichiers php.
2009-01-02 17:00:25 +01:00
}
else {
- LSsearch/LSsearchEntry : Added a new classes to doing and exploit ldap object search -> view/select => change to use it (php+template+js) -> LSattr_html_select_object/LSattr_html_select_list => change to use it -> LSldapObject : -> change listObjectsName() / searchObject() / getSelectArray() / listObjects() -> comment search() function -> Add triggers to clean cache -> LSpeople : Update search config -> LSsession : Change function to use it : - getSubDnLdapServer() - loadLSprofiles() - LSrelation : Deplace error codes declaration from LSsession in class file - LSldapObject : -> change getObjectFilter() / getLabel() / getSubDnValue() / getSubDnName() for can call then staticaly -> Add afterModify() function and trigger -> Change getObjectFilter() / listObjectsInRelation() to use Net_LDAP2_Filter -> Add __get() function -> Move one LSerror code for LSrelation function from LSsession class file -> Add a global variable to save cached data ($cache) -> Change subDn and subDnName access methods - LSauth : Move LSsession auth procedure in a dedicated class -> LSsession : Change startLSsession() to use it - LSsession : -> Add getRootDn() function -> Fix getTopDn() to return root DN if no topDn is currently defined -> Create dedicated functions to support recoveryPassword mecanism : - recoverPasswd() - recoverPasswdSendMail() - recoverPasswdFirstStep() - recoverPasswdSecondStep -> Customize LSdebug return and display (php+js) -> Clean unused error codes -> Move LSrelation error codes -> Comment ajax method
2009-10-30 01:03:17 +01:00
$basedn = self::getRootDn();
}
2021-08-25 18:02:37 +02:00
if (
isset($LSoject_config['displayName']) &&
!empty($LSoject_config['displayName'])
) {
$displayNameFormat = $LSoject_config['displayName'];
}
else {
2021-08-25 18:02:37 +02:00
$displayNameFormat = NULL;
- LdapSaisie : J'ai commencé à écrire la docummentation de LdapSaisie que j'espère pour voir bientôt ajouté au SVN. Cela me fait mettre le doit sur quelques problèmes de nommages, d'organisation que j'ai corrigé sur le fait : - Concepte de level était enfaite celui de subDn : seule le nom subDn doit rester. - Le concept de LSrights dans LSsession et config.inc.php était mal nommé. Il correspond plus à la définition de LSprofile en réalité. Je l'ai renommé ainsi. - Les paramètres authobject et authobject_pwdattr n'étaient pas très représentatif. Je les ai renommé en authObjectType et authObjectTypeAttrPwd. - Templates : -> Correction du template default dans le but de changer la couleur bleu dominante juger trop flashy :). Au passage j'ai dégagé l'image de fond de #main utilisé pour colorer le menu : cette méthode est moche et quitte a à faire du moche je préfère utiliser un vulgaire tableau que des bidouille de ce genre. -> Création d'un logo pour LdapSaisie qui vient remplacer le logo Easter-Eggs utilisé jusqu'alors. -> Ajout d'un favicon. - LSerror : -> J'ai déplacé les definitions de code d'erreur dans le contexte concerné (càd dans les fichiers de définition des classes) (Feature Request #1757) -> J'en ai profité pour renommer les codes d'erreur avec un prefixe pour eviter les doublons -> J'ai donc modifié une grande partie des fichiers pour changer les codes erreurs utilisés -> Ajout d'une méthode getError() utilisé par getErrors() -> Modification de la méthode stop() - LSformElement_password : - Correction d'un bug dans la génération des mots de passe dans un formulaire de création d'objet. - Ajout d'une possiblité de choisir le type de hashage du mot de passe stocké dans l'annuaire (Feature Request #1756) - Traduction des commentaires - LSattribute : Ajout des vérifications dans les méthodes de la classe lors de l'utilisation des objets html et ldap. - LSsession : -> Renforcement des méthodes faisant des inclusions d'autres fichiers php.
2009-01-02 17:00:25 +01:00
}
$sparams = array();
2021-08-25 18:02:37 +02:00
$sparams['onlyAccessible'] = (
isset($LSoject_config['onlyAccessible'])?
$LSoject_config['onlyAccessible']:
False
);
if( self :: loadLSobject($LSobject_name) ) {
- LdapSaisie : J'ai commencé à écrire la docummentation de LdapSaisie que j'espère pour voir bientôt ajouté au SVN. Cela me fait mettre le doit sur quelques problèmes de nommages, d'organisation que j'ai corrigé sur le fait : - Concepte de level était enfaite celui de subDn : seule le nom subDn doit rester. - Le concept de LSrights dans LSsession et config.inc.php était mal nommé. Il correspond plus à la définition de LSprofile en réalité. Je l'ai renommé ainsi. - Les paramètres authobject et authobject_pwdattr n'étaient pas très représentatif. Je les ai renommé en authObjectType et authObjectTypeAttrPwd. - Templates : -> Correction du template default dans le but de changer la couleur bleu dominante juger trop flashy :). Au passage j'ai dégagé l'image de fond de #main utilisé pour colorer le menu : cette méthode est moche et quitte a à faire du moche je préfère utiliser un vulgaire tableau que des bidouille de ce genre. -> Création d'un logo pour LdapSaisie qui vient remplacer le logo Easter-Eggs utilisé jusqu'alors. -> Ajout d'un favicon. - LSerror : -> J'ai déplacé les definitions de code d'erreur dans le contexte concerné (càd dans les fichiers de définition des classes) (Feature Request #1757) -> J'en ai profité pour renommer les codes d'erreur avec un prefixe pour eviter les doublons -> J'ai donc modifié une grande partie des fichiers pour changer les codes erreurs utilisés -> Ajout d'une méthode getError() utilisé par getErrors() -> Modification de la méthode stop() - LSformElement_password : - Correction d'un bug dans la génération des mots de passe dans un formulaire de création d'objet. - Ajout d'une possiblité de choisir le type de hashage du mot de passe stocké dans l'annuaire (Feature Request #1756) - Traduction des commentaires - LSattribute : Ajout des vérifications dans les méthodes de la classe lors de l'utilisation des objets html et ldap. - LSsession : -> Renforcement des méthodes faisant des inclusions d'autres fichiers php.
2009-01-02 17:00:25 +01:00
if ($subdnobject = new $LSobject_name()) {
2021-08-25 18:02:37 +02:00
$tbl_return = $subdnobject -> getSelectArray(
NULL, // pattern
$basedn, $displayNameFormat,
false, // approx
false, // cache
NULL, // filter
$sparams
);
- LdapSaisie : J'ai commencé à écrire la docummentation de LdapSaisie que j'espère pour voir bientôt ajouté au SVN. Cela me fait mettre le doit sur quelques problèmes de nommages, d'organisation que j'ai corrigé sur le fait : - Concepte de level était enfaite celui de subDn : seule le nom subDn doit rester. - Le concept de LSrights dans LSsession et config.inc.php était mal nommé. Il correspond plus à la définition de LSprofile en réalité. Je l'ai renommé ainsi. - Les paramètres authobject et authobject_pwdattr n'étaient pas très représentatif. Je les ai renommé en authObjectType et authObjectTypeAttrPwd. - Templates : -> Correction du template default dans le but de changer la couleur bleu dominante juger trop flashy :). Au passage j'ai dégagé l'image de fond de #main utilisé pour colorer le menu : cette méthode est moche et quitte a à faire du moche je préfère utiliser un vulgaire tableau que des bidouille de ce genre. -> Création d'un logo pour LdapSaisie qui vient remplacer le logo Easter-Eggs utilisé jusqu'alors. -> Ajout d'un favicon. - LSerror : -> J'ai déplacé les definitions de code d'erreur dans le contexte concerné (càd dans les fichiers de définition des classes) (Feature Request #1757) -> J'en ai profité pour renommer les codes d'erreur avec un prefixe pour eviter les doublons -> J'ai donc modifié une grande partie des fichiers pour changer les codes erreurs utilisés -> Ajout d'une méthode getError() utilisé par getErrors() -> Modification de la méthode stop() - LSformElement_password : - Correction d'un bug dans la génération des mots de passe dans un formulaire de création d'objet. - Ajout d'une possiblité de choisir le type de hashage du mot de passe stocké dans l'annuaire (Feature Request #1756) - Traduction des commentaires - LSattribute : Ajout des vérifications dans les méthodes de la classe lors de l'utilisation des objets html et ldap. - LSsession : -> Renforcement des méthodes faisant des inclusions d'autres fichiers php.
2009-01-02 17:00:25 +01:00
if (is_array($tbl_return)) {
2021-08-25 18:02:37 +02:00
$return = array_merge($return, $tbl_return);
}
else {
2021-08-25 18:02:37 +02:00
LSerror :: addErrorCode('LSsession_17', 3);
}
}
else {
2021-08-25 18:02:37 +02:00
LSerror :: addErrorCode('LSsession_17', 2);
}
}
}
}
else {
LSerror :: addErrorCode('LSsession_17',1);
}
}
2021-08-25 18:02:37 +02:00
elseif (
isCompatibleDNs(
$subDn_config['dn'],
self :: $ldapServer['ldap_config']['basedn']
) && $subDn_config['dn'] != ""
) {
$return[$subDn_config['dn']] = __($subDn_name);
}
}
if (self :: cacheSudDn()) {
2021-08-25 18:02:37 +02:00
self :: $_subDnLdapServer[self :: $ldapServerId][$login] = $return;
$_SESSION['LSsession_subDnLdapServer'] = self :: $_subDnLdapServer;
}
- LdapSaisie : J'ai commencé à écrire la docummentation de LdapSaisie que j'espère pour voir bientôt ajouté au SVN. Cela me fait mettre le doit sur quelques problèmes de nommages, d'organisation que j'ai corrigé sur le fait : - Concepte de level était enfaite celui de subDn : seule le nom subDn doit rester. - Le concept de LSrights dans LSsession et config.inc.php était mal nommé. Il correspond plus à la définition de LSprofile en réalité. Je l'ai renommé ainsi. - Les paramètres authobject et authobject_pwdattr n'étaient pas très représentatif. Je les ai renommé en authObjectType et authObjectTypeAttrPwd. - Templates : -> Correction du template default dans le but de changer la couleur bleu dominante juger trop flashy :). Au passage j'ai dégagé l'image de fond de #main utilisé pour colorer le menu : cette méthode est moche et quitte a à faire du moche je préfère utiliser un vulgaire tableau que des bidouille de ce genre. -> Création d'un logo pour LdapSaisie qui vient remplacer le logo Easter-Eggs utilisé jusqu'alors. -> Ajout d'un favicon. - LSerror : -> J'ai déplacé les definitions de code d'erreur dans le contexte concerné (càd dans les fichiers de définition des classes) (Feature Request #1757) -> J'en ai profité pour renommer les codes d'erreur avec un prefixe pour eviter les doublons -> J'ai donc modifié une grande partie des fichiers pour changer les codes erreurs utilisés -> Ajout d'une méthode getError() utilisé par getErrors() -> Modification de la méthode stop() - LSformElement_password : - Correction d'un bug dans la génération des mots de passe dans un formulaire de création d'objet. - Ajout d'une possiblité de choisir le type de hashage du mot de passe stocké dans l'annuaire (Feature Request #1756) - Traduction des commentaires - LSattribute : Ajout des vérifications dans les méthodes de la classe lors de l'utilisation des objets html et ldap. - LSsession : -> Renforcement des méthodes faisant des inclusions d'autres fichiers php.
2009-01-02 17:00:25 +01:00
return $return;
}
2020-04-29 15:54:21 +02:00
/**
2021-08-25 18:02:37 +02:00
* Retrieve currently used LDAP server subDn list sorted by depth
* in the LDAP tree (descending order)
2020-04-29 15:54:21 +02:00
*
2021-08-25 18:02:37 +02:00
* @return array Sorted array of LDAP server subDns
2020-04-29 15:54:21 +02:00
*/
public static function getSortSubDnLdapServer($login=false) {
$subDnLdapServer = self :: getSubDnLdapServer($login);
if (!$subDnLdapServer) {
return array();
}
2021-08-25 18:02:37 +02:00
uksort($subDnLdapServer, "compareDn");
return $subDnLdapServer;
}
/**
2021-08-25 18:02:37 +02:00
* Retrieve HTML options of current LDAP server topDNs
*
* @return string|false HTML options of current LDAP server topDNs, or false in case of error
*/
2021-08-25 18:02:37 +02:00
public static function getSubDnLdapServerOptions($selected=NULL, $login=false) {
$list = self :: getSubDnLdapServer($login);
2021-08-25 18:02:37 +02:00
if (!$list)
return false;
2021-08-25 18:02:37 +02:00
asort($list);
$options = array();
foreach($list as $dn => $txt) {
$options[] = (
"<option value=\"$dn\"".(
$selected && $selected == $dn?
" selected":
""
).">$txt</option>"
);
}
2021-08-25 18:02:37 +02:00
return implode('', $options);
}
/**
2021-08-25 18:02:37 +02:00
* Check a subDn is valid
*
* @param string $subDn The subDn to check
2020-04-29 15:54:21 +02:00
*
* @return boolean True if subDn is valid, False otherwise
*/
public static function validSubDnLdapServer($subDn) {
$listTopDn = self :: getSubDnLdapServer();
if(is_array($listTopDn)) {
foreach($listTopDn as $dn => $txt) {
if ($subDn==$dn) {
return true;
} // end if
} // end foreach
} // end if
return false;
}
/**
2021-08-25 18:02:37 +02:00
* Check a user password from an LSobject and a password
*
2021-08-25 18:02:37 +02:00
* Try to bind on LDAP server using the provided LSobject DN and password.
*
* @param LSldapObject $object The user LSobject
* @param string $pwd The password to check
*
* @return boolean True on authentication success, false otherwise.
*/
2021-08-25 18:02:37 +02:00
public static function checkUserPwd($object, $pwd) {
return LSldap :: checkBind($object -> getValue('dn'), $pwd);
}
/**
2021-08-25 18:02:37 +02:00
* Display login form
*
2021-08-25 18:02:37 +02:00
* Define template information allowing to display login form.
*
* @return void
*/
public static function displayLoginForm() {
LStemplate :: assign('pagetitle', _('Connection'));
$ldapservers = array();
foreach(LSconfig :: get('ldap_servers') as $id => $infos)
$ldapservers[$id] = __($infos['name']);
LStemplate :: assign('ldapservers', $ldapservers);
LStemplate :: assign('ldapServerId', (self :: $ldapServerId?self :: $ldapServerId:0));
self :: setTemplate('login.tpl');
LStemplate :: addJSscript('LSsession_login.js');
}
/**
2021-08-25 18:02:37 +02:00
* Display password recovery form
*
2021-08-25 18:02:37 +02:00
* Define template information allowing to display password recovery form.
2020-04-29 15:54:21 +02:00
*
* @param array $recoveryPasswordInfos Password recovery process state information
*
* @return void
*/
public static function displayRecoverPasswordForm($recoveryPasswordInfos) {
LStemplate :: assign('pagetitle', _('Recovery of your credentials'));
$ldapservers = array();
foreach(LSconfig :: get('ldap_servers') as $id => $infos)
$ldapservers[$id] = __($infos['name']);
LStemplate :: assign('ldapservers', $ldapservers);
LStemplate :: assign('ldapServerId', (self :: $ldapServerId?self :: $ldapServerId:0));
2020-04-29 15:54:21 +02:00
2019-03-08 11:26:54 +01:00
$recoverpassword_step = 'start';
$recoverpassword_msg = _('Please fill the identifier field to proceed recovery procedure');
2020-04-29 15:54:21 +02:00
if (isset($recoveryPasswordInfos['recoveryHashMail'])) {
2019-03-08 11:26:54 +01:00
$recoverpassword_step = 'token_sent';
$recoverpassword_msg = getFData(
_("An email has been sent to %{mail}. " .
"Please follow the instructions on it."),
$recoveryPasswordInfos['recoveryHashMail']
);
}
2020-04-29 15:54:21 +02:00
if (isset($recoveryPasswordInfos['newPasswordMail'])) {
2019-03-08 11:26:54 +01:00
$recoverpassword_step = 'new_password_sent';
$recoverpassword_msg = getFData(
2020-04-29 15:38:41 +02:00
_("Your new password has been sent to %{mail}."),
$recoveryPasswordInfos['newPasswordMail']
);
}
2020-04-29 15:54:21 +02:00
LStemplate :: assign('recoverpassword_step', $recoverpassword_step);
LStemplate :: assign('recoverpassword_msg', $recoverpassword_msg);
2020-04-29 15:54:21 +02:00
self :: setTemplate('recoverpassword.tpl');
LStemplate :: addJSscript('LSsession_recoverPassword.js');
}
/**
2021-08-25 18:02:37 +02:00
* Set the template file that will display
*
2021-08-25 18:02:37 +02:00
* Note: template files are normally store in templates directory.
*
* @param string $template The name of the template file
*
* @return void
*/
public static function setTemplate($template) {
self :: $template = $template;
}
/**
* Add a JS script to load on page
*
* @param string $file The JS filename
* @param string|null $path The sub-directory path that contain this file.
* @deprecated
* @see LStemplate :: addJSscript()
*
* @return void
*/
public static function addJSscript($file, $path=NULL) {
if ($path)
$file = $path.$file;
LStemplate :: addJSscript($file);
LSerror :: addErrorCode(
'LSsession_27',
array(
2020-06-04 19:05:23 +02:00
'old' => 'LSsession :: addJSscript()',
'new' => 'LStemplate :: addJSscript()',
'context' => LSlog :: get_debug_backtrace_context(),
)
);
}
/**
* Add a library JS file to load on page
*
* @param string $file The JS filename
* @deprecated
* @see LStemplate :: addLibJSscript()
*
* @return void
*/
public static function addLibJSscript($file) {
LStemplate :: addLibJSscript($file);
LSerror :: addErrorCode(
'LSsession_27',
array(
2020-06-04 19:05:23 +02:00
'old' => 'LSsession :: addLibJSscript()',
'new' => 'LStemplate :: addLibJSscript()',
'context' => LSlog :: get_debug_backtrace_context(),
)
);
}
- config.inc.php : Ajout d'une constante LS_CSS_DIR - Ajout d'un LSformElement Date : -> includes/class/class.LSattr_ldap_date.php -> includes/class/class.LSattr_html_date.php -> includes/class/class.LSformElement_date.php -> includes/class/class.LSformRule_date.php -> includes/libs/jscalendar -> includes/js/LSformElement_date.js -> includes/js/LSformElement_date_field.js -> templates/images/calendar.png - LSformElement : Ajout d'une méthode exportValues() utilisée par LSform::exportValues() - LSform : -> Utlisation de LSformElement::exportValues() pour exporter les données du formulaire -> Méthode setValuesFromPostData() est désormais invoqué à chaque invocation de la méthode validate() - LSformElement_select_object : Ajout d'une méthode exportValues() pour coller au nouveau mode d'exportation des données de l'annuaire - LSldapObjet : Correction d'un bug potentiel (foreach sur une variable à false) dans la méthode updateData() - LSsession : -> Méthode addCssFile() & addJSscript() : ajout d'un paramètre pour la possibilité d'inclusion de fichier externe (hors des dossiers par défaut ex: les libs) -> Utilisation de la Constante LS_CSS_DIR au lieu d'une chemin en dure -> Paramètrage JS depuis Php : -> Méthode addJSconfigParam() : ajouter un paramètre de config. JS -> Méthode displayTemplate() adaptée pour -> top.tpl : adapté pour afficher une div contenant les paramètres JSONisés -> LSdefault.css : adapté pour ne pas afficher la div contenant les params. -> LSdefault.js : récupère les informations et Initialise une variable javascript LSjsConfig - LSconfirmBox : Correction d'un debug : "delete this;"
2008-07-18 16:02:46 +02:00
/**
2021-08-25 18:02:37 +02:00
* Add Javascript configuration parameter
2020-04-29 15:54:21 +02:00
*
* @param string $name The name of the JS config paramenter
* @param string $val The value of the JS config paramenter
* @deprecated
* @see LStemplate :: addJSconfigParam()
- config.inc.php : Ajout d'une constante LS_CSS_DIR - Ajout d'un LSformElement Date : -> includes/class/class.LSattr_ldap_date.php -> includes/class/class.LSattr_html_date.php -> includes/class/class.LSformElement_date.php -> includes/class/class.LSformRule_date.php -> includes/libs/jscalendar -> includes/js/LSformElement_date.js -> includes/js/LSformElement_date_field.js -> templates/images/calendar.png - LSformElement : Ajout d'une méthode exportValues() utilisée par LSform::exportValues() - LSform : -> Utlisation de LSformElement::exportValues() pour exporter les données du formulaire -> Méthode setValuesFromPostData() est désormais invoqué à chaque invocation de la méthode validate() - LSformElement_select_object : Ajout d'une méthode exportValues() pour coller au nouveau mode d'exportation des données de l'annuaire - LSldapObjet : Correction d'un bug potentiel (foreach sur une variable à false) dans la méthode updateData() - LSsession : -> Méthode addCssFile() & addJSscript() : ajout d'un paramètre pour la possibilité d'inclusion de fichier externe (hors des dossiers par défaut ex: les libs) -> Utilisation de la Constante LS_CSS_DIR au lieu d'une chemin en dure -> Paramètrage JS depuis Php : -> Méthode addJSconfigParam() : ajouter un paramètre de config. JS -> Méthode displayTemplate() adaptée pour -> top.tpl : adapté pour afficher une div contenant les paramètres JSONisés -> LSdefault.css : adapté pour ne pas afficher la div contenant les params. -> LSdefault.js : récupère les informations et Initialise une variable javascript LSjsConfig - LSconfirmBox : Correction d'un debug : "delete this;"
2008-07-18 16:02:46 +02:00
*
* @return void
- config.inc.php : Ajout d'une constante LS_CSS_DIR - Ajout d'un LSformElement Date : -> includes/class/class.LSattr_ldap_date.php -> includes/class/class.LSattr_html_date.php -> includes/class/class.LSformElement_date.php -> includes/class/class.LSformRule_date.php -> includes/libs/jscalendar -> includes/js/LSformElement_date.js -> includes/js/LSformElement_date_field.js -> templates/images/calendar.png - LSformElement : Ajout d'une méthode exportValues() utilisée par LSform::exportValues() - LSform : -> Utlisation de LSformElement::exportValues() pour exporter les données du formulaire -> Méthode setValuesFromPostData() est désormais invoqué à chaque invocation de la méthode validate() - LSformElement_select_object : Ajout d'une méthode exportValues() pour coller au nouveau mode d'exportation des données de l'annuaire - LSldapObjet : Correction d'un bug potentiel (foreach sur une variable à false) dans la méthode updateData() - LSsession : -> Méthode addCssFile() & addJSscript() : ajout d'un paramètre pour la possibilité d'inclusion de fichier externe (hors des dossiers par défaut ex: les libs) -> Utilisation de la Constante LS_CSS_DIR au lieu d'une chemin en dure -> Paramètrage JS depuis Php : -> Méthode addJSconfigParam() : ajouter un paramètre de config. JS -> Méthode displayTemplate() adaptée pour -> top.tpl : adapté pour afficher une div contenant les paramètres JSONisés -> LSdefault.css : adapté pour ne pas afficher la div contenant les params. -> LSdefault.js : récupère les informations et Initialise une variable javascript LSjsConfig - LSconfirmBox : Correction d'un debug : "delete this;"
2008-07-18 16:02:46 +02:00
*/
public static function addJSconfigParam($name, $val) {
LStemplate :: addJSconfigParam($name, $val);
LSerror :: addErrorCode(
'LSsession_27',
array(
2020-06-04 19:05:23 +02:00
'old' => 'LSsession :: addJSconfigParam()',
'new' => 'LStemplate :: addJSconfigParam()',
'context' => LSlog :: get_debug_backtrace_context(),
),
false
);
- config.inc.php : Ajout d'une constante LS_CSS_DIR - Ajout d'un LSformElement Date : -> includes/class/class.LSattr_ldap_date.php -> includes/class/class.LSattr_html_date.php -> includes/class/class.LSformElement_date.php -> includes/class/class.LSformRule_date.php -> includes/libs/jscalendar -> includes/js/LSformElement_date.js -> includes/js/LSformElement_date_field.js -> templates/images/calendar.png - LSformElement : Ajout d'une méthode exportValues() utilisée par LSform::exportValues() - LSform : -> Utlisation de LSformElement::exportValues() pour exporter les données du formulaire -> Méthode setValuesFromPostData() est désormais invoqué à chaque invocation de la méthode validate() - LSformElement_select_object : Ajout d'une méthode exportValues() pour coller au nouveau mode d'exportation des données de l'annuaire - LSldapObjet : Correction d'un bug potentiel (foreach sur une variable à false) dans la méthode updateData() - LSsession : -> Méthode addCssFile() & addJSscript() : ajout d'un paramètre pour la possibilité d'inclusion de fichier externe (hors des dossiers par défaut ex: les libs) -> Utilisation de la Constante LS_CSS_DIR au lieu d'une chemin en dure -> Paramètrage JS depuis Php : -> Méthode addJSconfigParam() : ajouter un paramètre de config. JS -> Méthode displayTemplate() adaptée pour -> top.tpl : adapté pour afficher une div contenant les paramètres JSONisés -> LSdefault.css : adapté pour ne pas afficher la div contenant les params. -> LSdefault.js : récupère les informations et Initialise une variable javascript LSjsConfig - LSconfirmBox : Correction d'un debug : "delete this;"
2008-07-18 16:02:46 +02:00
}
/**
* Add a CSS file to load on page
*
* @param string $file The CSS filename
* @param string|null $path The sub-directory path that contain this file.
* @deprecated
* @see LStemplate :: addCssFile()
*
* @return void
*/
public static function addCssFile($file, $path=NULL) {
if ($path)
2013-06-19 03:06:29 +02:00
$file = $path.$file;
LStemplate :: addCssFile($file);
LSerror :: addErrorCode(
'LSsession_27',
array(
2020-06-04 19:05:23 +02:00
'old' => 'LSsession :: addCssFile()',
'new' => 'LStemplate :: addCssFile()',
'context' => LSlog :: get_debug_backtrace_context(),
)
);
}
/**
* Add a library CSS file to load on page
*
* @param string $file The CSS filename
* @deprecated
* @see LStemplate :: addLibCssFile()
*
* @return void
*/
public static function addLibCssFile($file) {
LStemplate :: addLibCssFile($file);
LSerror :: addErrorCode(
'LSsession_27',
array(
2020-06-04 19:05:23 +02:00
'old' => 'LSsession :: addLibCssFile()',
'new' => 'LStemplate :: addLibCssFile()',
'context' => LSlog :: get_debug_backtrace_context(),
)
);
}
/**
2021-08-25 18:02:37 +02:00
* Show the template
*
2021-08-25 18:02:37 +02:00
* Load dependencies of show the previously selected template file
*
* @return void
*/
public static function displayTemplate() {
if (self :: $api_mode) {
self :: displayAjaxReturn();
return;
}
$KAconf = LSconfig :: get('keepLSsessionActive');
2020-04-29 15:54:21 +02:00
if (
2021-08-25 18:02:37 +02:00
(
(!isset(self :: $ldapServer['keepLSsessionActive']))
&&
(!($KAconf === false))
) || self :: $ldapServer['keepLSsessionActive']
) {
LStemplate :: addJSconfigParam(
'keepLSsessionActive', ini_get('session.gc_maxlifetime')
);
}
2020-04-29 15:54:21 +02:00
// Access
LStemplate :: assign('LSaccess', self :: getLSaccess());
LStemplate :: assign('LSaddonsViewsAccess', self :: $LSaddonsViewsAccess);
2020-04-29 15:54:21 +02:00
// Niveau
$listTopDn = self :: getSubDnLdapServer();
if (is_array($listTopDn)) {
asort($listTopDn);
2021-08-25 18:02:37 +02:00
LStemplate :: assign('LSsession_subDn_level', self :: getSubDnLabel());
LStemplate :: assign('LSsession_subDn_refresh', _('Refresh'));
$LSsession_topDn_index = array();
$LSsession_topDn_name = array();
foreach($listTopDn as $index => $name) {
2021-08-25 18:02:37 +02:00
$LSsession_topDn_index[] = $index;
$LSsession_topDn_name[] = $name;
}
2021-08-25 18:02:37 +02:00
LStemplate :: assign('LSsession_subDn_indexes', $LSsession_topDn_index);
LStemplate :: assign('LSsession_subDn_names', $LSsession_topDn_name);
LStemplate :: assign('LSsession_subDn', self :: $topDn);
LStemplate :: assign('LSsession_subDnName', self :: getSubDnName());
}
2020-04-29 15:54:21 +02:00
LStemplate :: assign('LSlanguages', LSlang :: getLangList());
LStemplate :: assign('LSlang', LSlang :: getLang());
LStemplate :: assign('LSencoding', LSlang :: getEncoding());
2020-04-29 15:54:21 +02:00
2021-08-25 18:02:37 +02:00
LStemplate :: assign('displayLogoutBtn', LSauth :: displayLogoutBtn());
LStemplate :: assign('displaySelfAccess', LSauth :: displaySelfAccess());
// Infos
LStemplate :: assign(
'LSinfos',
base64_encode(
json_encode(
isset($_SESSION['LSsession_infos']) && is_array($_SESSION['LSsession_infos'])?
$_SESSION['LSsession_infos']:
array()
)
)
);
$_SESSION['LSsession_infos'] = array();
// Errors
LSerror :: display();
// LSdebug
LSdebug_print();
2020-04-29 15:54:21 +02:00
if (!self :: $template)
2020-05-07 12:16:12 +02:00
self :: setTemplate('base_connected.tpl');
2020-04-29 15:54:21 +02:00
LStemplate :: display(self :: $template);
}
2020-04-29 15:54:21 +02:00
/**
Add API feature Some major changes have been made to handle this new feature : - LSsession now have a flag about API mode. The displayTemplate() and displayAjaxReturn() methods have been adjust to correctly handle this mode. - LSauth system have been adjust to handle a custom API mode : - LSauthMethod can support or not this mode : the $api_mode_supported permit to defined if supported (default, false). Currently, only HTTP (default in API mode) and annonymous mode support it. - An api_access parameter permit to configure witch type of user LSobject types could use the API. This flag must be set to True to allow a type of LSobject (default: False). In a same way, a web_access parameter now permit to disable Web access for some types of users (but this parameter is optional and its default value is True). - The HTTP method is the privileged first method for API mode. In this mode, if auth data aren't present in environment, it will request it by triggered a 403 HTTP error. Realm can be configured with new LSAUTHMETHOD_HTTP_API_REALM constant. - The LStemplate system handle API mode to correctly react on errors: it return a JSON answer instead of HTML page. Error pages also now return adjusted HTTP code (404 or 500). - The LSurl system have been adjust to handle API mode : - On declaring handlers, we could now specify if it's an API view with new $api_mode paremeter of add_handler() method - The LSurlRequest object have a new attribute to check if it's an API request - The error_404() method handle the API mode to return JSON answer. Furthermore, if no handlers matched with the requested URL, API mode is automatically enabled if the requested URL starts with 'api/'. - LSform implement it own API mode flag and a new submited flag that be toggle via the new setSubmited() method. Some major changes also occured on LSformElement classes to specifically handle API input/output for each types of attributes: - a new getApiValue() method permit to retrieve the API value of the attribute (on show API view) - the getPostData() method now have to correctly handle API input for the attribute (on create/modify API views). A programmatic way have been adopted for each types of attributes. - The LSimport and LScli create/modify commands also evolved to enable API mode of the LSform. This permit to take advantage of the new capability of LSform/LSformElement to handle input values with a programmatic way. - New routes have been add to handle API views. All this new routes start with 'api/1.0/' and use the same URL schema as the web UI. The API currently permit to search/show/add/modify/remove LSobjects and manages their relations.
2021-02-03 14:40:28 +01:00
* Set Ajax display mode
*
* @param boolean $val True to enable Ajax display mode (optional, default: true)
2020-04-29 15:54:21 +02:00
*
* @return void
*/
public static function setAjaxDisplay($val=true) {
self :: $ajaxDisplay = (boolean)$val;
}
2020-04-29 15:54:21 +02:00
Add API feature Some major changes have been made to handle this new feature : - LSsession now have a flag about API mode. The displayTemplate() and displayAjaxReturn() methods have been adjust to correctly handle this mode. - LSauth system have been adjust to handle a custom API mode : - LSauthMethod can support or not this mode : the $api_mode_supported permit to defined if supported (default, false). Currently, only HTTP (default in API mode) and annonymous mode support it. - An api_access parameter permit to configure witch type of user LSobject types could use the API. This flag must be set to True to allow a type of LSobject (default: False). In a same way, a web_access parameter now permit to disable Web access for some types of users (but this parameter is optional and its default value is True). - The HTTP method is the privileged first method for API mode. In this mode, if auth data aren't present in environment, it will request it by triggered a 403 HTTP error. Realm can be configured with new LSAUTHMETHOD_HTTP_API_REALM constant. - The LStemplate system handle API mode to correctly react on errors: it return a JSON answer instead of HTML page. Error pages also now return adjusted HTTP code (404 or 500). - The LSurl system have been adjust to handle API mode : - On declaring handlers, we could now specify if it's an API view with new $api_mode paremeter of add_handler() method - The LSurlRequest object have a new attribute to check if it's an API request - The error_404() method handle the API mode to return JSON answer. Furthermore, if no handlers matched with the requested URL, API mode is automatically enabled if the requested URL starts with 'api/'. - LSform implement it own API mode flag and a new submited flag that be toggle via the new setSubmited() method. Some major changes also occured on LSformElement classes to specifically handle API input/output for each types of attributes: - a new getApiValue() method permit to retrieve the API value of the attribute (on show API view) - the getPostData() method now have to correctly handle API input for the attribute (on create/modify API views). A programmatic way have been adopted for each types of attributes. - The LSimport and LScli create/modify commands also evolved to enable API mode of the LSform. This permit to take advantage of the new capability of LSform/LSformElement to handle input values with a programmatic way. - New routes have been add to handle API views. All this new routes start with 'api/1.0/' and use the same URL schema as the web UI. The API currently permit to search/show/add/modify/remove LSobjects and manages their relations.
2021-02-03 14:40:28 +01:00
/**
* Check if Ajax display mode is enabled
*
* @return boolean True if Ajax display mode is enabled, False otherwise
Add API feature Some major changes have been made to handle this new feature : - LSsession now have a flag about API mode. The displayTemplate() and displayAjaxReturn() methods have been adjust to correctly handle this mode. - LSauth system have been adjust to handle a custom API mode : - LSauthMethod can support or not this mode : the $api_mode_supported permit to defined if supported (default, false). Currently, only HTTP (default in API mode) and annonymous mode support it. - An api_access parameter permit to configure witch type of user LSobject types could use the API. This flag must be set to True to allow a type of LSobject (default: False). In a same way, a web_access parameter now permit to disable Web access for some types of users (but this parameter is optional and its default value is True). - The HTTP method is the privileged first method for API mode. In this mode, if auth data aren't present in environment, it will request it by triggered a 403 HTTP error. Realm can be configured with new LSAUTHMETHOD_HTTP_API_REALM constant. - The LStemplate system handle API mode to correctly react on errors: it return a JSON answer instead of HTML page. Error pages also now return adjusted HTTP code (404 or 500). - The LSurl system have been adjust to handle API mode : - On declaring handlers, we could now specify if it's an API view with new $api_mode paremeter of add_handler() method - The LSurlRequest object have a new attribute to check if it's an API request - The error_404() method handle the API mode to return JSON answer. Furthermore, if no handlers matched with the requested URL, API mode is automatically enabled if the requested URL starts with 'api/'. - LSform implement it own API mode flag and a new submited flag that be toggle via the new setSubmited() method. Some major changes also occured on LSformElement classes to specifically handle API input/output for each types of attributes: - a new getApiValue() method permit to retrieve the API value of the attribute (on show API view) - the getPostData() method now have to correctly handle API input for the attribute (on create/modify API views). A programmatic way have been adopted for each types of attributes. - The LSimport and LScli create/modify commands also evolved to enable API mode of the LSform. This permit to take advantage of the new capability of LSform/LSformElement to handle input values with a programmatic way. - New routes have been add to handle API views. All this new routes start with 'api/1.0/' and use the same URL schema as the web UI. The API currently permit to search/show/add/modify/remove LSobjects and manages their relations.
2021-02-03 14:40:28 +01:00
*/
public static function getAjaxDisplay() {
return (boolean)self :: $ajaxDisplay;
}
/**
2021-08-25 18:02:37 +02:00
* Show Ajax return
*
* @return void
*/
Add API feature Some major changes have been made to handle this new feature : - LSsession now have a flag about API mode. The displayTemplate() and displayAjaxReturn() methods have been adjust to correctly handle this mode. - LSauth system have been adjust to handle a custom API mode : - LSauthMethod can support or not this mode : the $api_mode_supported permit to defined if supported (default, false). Currently, only HTTP (default in API mode) and annonymous mode support it. - An api_access parameter permit to configure witch type of user LSobject types could use the API. This flag must be set to True to allow a type of LSobject (default: False). In a same way, a web_access parameter now permit to disable Web access for some types of users (but this parameter is optional and its default value is True). - The HTTP method is the privileged first method for API mode. In this mode, if auth data aren't present in environment, it will request it by triggered a 403 HTTP error. Realm can be configured with new LSAUTHMETHOD_HTTP_API_REALM constant. - The LStemplate system handle API mode to correctly react on errors: it return a JSON answer instead of HTML page. Error pages also now return adjusted HTTP code (404 or 500). - The LSurl system have been adjust to handle API mode : - On declaring handlers, we could now specify if it's an API view with new $api_mode paremeter of add_handler() method - The LSurlRequest object have a new attribute to check if it's an API request - The error_404() method handle the API mode to return JSON answer. Furthermore, if no handlers matched with the requested URL, API mode is automatically enabled if the requested URL starts with 'api/'. - LSform implement it own API mode flag and a new submited flag that be toggle via the new setSubmited() method. Some major changes also occured on LSformElement classes to specifically handle API input/output for each types of attributes: - a new getApiValue() method permit to retrieve the API value of the attribute (on show API view) - the getPostData() method now have to correctly handle API input for the attribute (on create/modify API views). A programmatic way have been adopted for each types of attributes. - The LSimport and LScli create/modify commands also evolved to enable API mode of the LSform. This permit to take advantage of the new capability of LSform/LSformElement to handle input values with a programmatic way. - New routes have been add to handle API views. All this new routes start with 'api/1.0/' and use the same URL schema as the web UI. The API currently permit to search/show/add/modify/remove LSobjects and manages their relations.
2021-02-03 14:40:28 +01:00
public static function displayAjaxReturn($data=array(), $pretty=false) {
2021-02-04 10:22:10 +01:00
// Adjust content-type
header('Content-Type: application/json');
// Adjust HTTP error code on unsuccessfull request
if (isset($data['success']) && !$data['success'] && http_response_code() == 200)
http_response_code(400);
// If redirection set, just redirect user and not handling messages/errors to
2021-02-04 10:22:10 +01:00
// keep it in session and show it on next page
if (!isset($data['LSredirect']) || LSdebugDefined()) {
if (!self :: $api_mode && class_exists('LStemplate'))
$data['LSjsConfig'] = LStemplate :: getJSconfigParam();
// Infos
if(
!empty($_SESSION['LSsession_infos']) &&
is_array($_SESSION['LSsession_infos'])
) {
Add API feature Some major changes have been made to handle this new feature : - LSsession now have a flag about API mode. The displayTemplate() and displayAjaxReturn() methods have been adjust to correctly handle this mode. - LSauth system have been adjust to handle a custom API mode : - LSauthMethod can support or not this mode : the $api_mode_supported permit to defined if supported (default, false). Currently, only HTTP (default in API mode) and annonymous mode support it. - An api_access parameter permit to configure witch type of user LSobject types could use the API. This flag must be set to True to allow a type of LSobject (default: False). In a same way, a web_access parameter now permit to disable Web access for some types of users (but this parameter is optional and its default value is True). - The HTTP method is the privileged first method for API mode. In this mode, if auth data aren't present in environment, it will request it by triggered a 403 HTTP error. Realm can be configured with new LSAUTHMETHOD_HTTP_API_REALM constant. - The LStemplate system handle API mode to correctly react on errors: it return a JSON answer instead of HTML page. Error pages also now return adjusted HTTP code (404 or 500). - The LSurl system have been adjust to handle API mode : - On declaring handlers, we could now specify if it's an API view with new $api_mode paremeter of add_handler() method - The LSurlRequest object have a new attribute to check if it's an API request - The error_404() method handle the API mode to return JSON answer. Furthermore, if no handlers matched with the requested URL, API mode is automatically enabled if the requested URL starts with 'api/'. - LSform implement it own API mode flag and a new submited flag that be toggle via the new setSubmited() method. Some major changes also occured on LSformElement classes to specifically handle API input/output for each types of attributes: - a new getApiValue() method permit to retrieve the API value of the attribute (on show API view) - the getPostData() method now have to correctly handle API input for the attribute (on create/modify API views). A programmatic way have been adopted for each types of attributes. - The LSimport and LScli create/modify commands also evolved to enable API mode of the LSform. This permit to take advantage of the new capability of LSform/LSformElement to handle input values with a programmatic way. - New routes have been add to handle API views. All this new routes start with 'api/1.0/' and use the same URL schema as the web UI. The API currently permit to search/show/add/modify/remove LSobjects and manages their relations.
2021-02-03 14:40:28 +01:00
$data['messages'] = $_SESSION['LSsession_infos'];
$_SESSION['LSsession_infos'] = array();
Add API feature Some major changes have been made to handle this new feature : - LSsession now have a flag about API mode. The displayTemplate() and displayAjaxReturn() methods have been adjust to correctly handle this mode. - LSauth system have been adjust to handle a custom API mode : - LSauthMethod can support or not this mode : the $api_mode_supported permit to defined if supported (default, false). Currently, only HTTP (default in API mode) and annonymous mode support it. - An api_access parameter permit to configure witch type of user LSobject types could use the API. This flag must be set to True to allow a type of LSobject (default: False). In a same way, a web_access parameter now permit to disable Web access for some types of users (but this parameter is optional and its default value is True). - The HTTP method is the privileged first method for API mode. In this mode, if auth data aren't present in environment, it will request it by triggered a 403 HTTP error. Realm can be configured with new LSAUTHMETHOD_HTTP_API_REALM constant. - The LStemplate system handle API mode to correctly react on errors: it return a JSON answer instead of HTML page. Error pages also now return adjusted HTTP code (404 or 500). - The LSurl system have been adjust to handle API mode : - On declaring handlers, we could now specify if it's an API view with new $api_mode paremeter of add_handler() method - The LSurlRequest object have a new attribute to check if it's an API request - The error_404() method handle the API mode to return JSON answer. Furthermore, if no handlers matched with the requested URL, API mode is automatically enabled if the requested URL starts with 'api/'. - LSform implement it own API mode flag and a new submited flag that be toggle via the new setSubmited() method. Some major changes also occured on LSformElement classes to specifically handle API input/output for each types of attributes: - a new getApiValue() method permit to retrieve the API value of the attribute (on show API view) - the getPostData() method now have to correctly handle API input for the attribute (on create/modify API views). A programmatic way have been adopted for each types of attributes. - The LSimport and LScli create/modify commands also evolved to enable API mode of the LSform. This permit to take advantage of the new capability of LSform/LSformElement to handle input values with a programmatic way. - New routes have been add to handle API views. All this new routes start with 'api/1.0/' and use the same URL schema as the web UI. The API currently permit to search/show/add/modify/remove LSobjects and manages their relations.
2021-02-03 14:40:28 +01:00
}
if (LSerror :: errorsDefined()) {
$data['errors'] = LSerror :: getErrors();
}
2020-04-29 15:54:21 +02:00
if (!self :: $api_mode && LSdebugDefined()) {
$data['LSdebug'] = LSdebug_print(true);
}
}
Add API feature Some major changes have been made to handle this new feature : - LSsession now have a flag about API mode. The displayTemplate() and displayAjaxReturn() methods have been adjust to correctly handle this mode. - LSauth system have been adjust to handle a custom API mode : - LSauthMethod can support or not this mode : the $api_mode_supported permit to defined if supported (default, false). Currently, only HTTP (default in API mode) and annonymous mode support it. - An api_access parameter permit to configure witch type of user LSobject types could use the API. This flag must be set to True to allow a type of LSobject (default: False). In a same way, a web_access parameter now permit to disable Web access for some types of users (but this parameter is optional and its default value is True). - The HTTP method is the privileged first method for API mode. In this mode, if auth data aren't present in environment, it will request it by triggered a 403 HTTP error. Realm can be configured with new LSAUTHMETHOD_HTTP_API_REALM constant. - The LStemplate system handle API mode to correctly react on errors: it return a JSON answer instead of HTML page. Error pages also now return adjusted HTTP code (404 or 500). - The LSurl system have been adjust to handle API mode : - On declaring handlers, we could now specify if it's an API view with new $api_mode paremeter of add_handler() method - The LSurlRequest object have a new attribute to check if it's an API request - The error_404() method handle the API mode to return JSON answer. Furthermore, if no handlers matched with the requested URL, API mode is automatically enabled if the requested URL starts with 'api/'. - LSform implement it own API mode flag and a new submited flag that be toggle via the new setSubmited() method. Some major changes also occured on LSformElement classes to specifically handle API input/output for each types of attributes: - a new getApiValue() method permit to retrieve the API value of the attribute (on show API view) - the getPostData() method now have to correctly handle API input for the attribute (on create/modify API views). A programmatic way have been adopted for each types of attributes. - The LSimport and LScli create/modify commands also evolved to enable API mode of the LSform. This permit to take advantage of the new capability of LSform/LSformElement to handle input values with a programmatic way. - New routes have been add to handle API views. All this new routes start with 'api/1.0/' and use the same URL schema as the web UI. The API currently permit to search/show/add/modify/remove LSobjects and manages their relations.
2021-02-03 14:40:28 +01:00
if (!self :: $api_mode && isset($_REQUEST['imgload'])) {
$data['imgload'] = $_REQUEST['imgload'];
}
echo json_encode(
$data,
(
$pretty || isset($_REQUEST['pretty'])?
JSON_PRETTY_PRINT:
0
)
);
Add API feature Some major changes have been made to handle this new feature : - LSsession now have a flag about API mode. The displayTemplate() and displayAjaxReturn() methods have been adjust to correctly handle this mode. - LSauth system have been adjust to handle a custom API mode : - LSauthMethod can support or not this mode : the $api_mode_supported permit to defined if supported (default, false). Currently, only HTTP (default in API mode) and annonymous mode support it. - An api_access parameter permit to configure witch type of user LSobject types could use the API. This flag must be set to True to allow a type of LSobject (default: False). In a same way, a web_access parameter now permit to disable Web access for some types of users (but this parameter is optional and its default value is True). - The HTTP method is the privileged first method for API mode. In this mode, if auth data aren't present in environment, it will request it by triggered a 403 HTTP error. Realm can be configured with new LSAUTHMETHOD_HTTP_API_REALM constant. - The LStemplate system handle API mode to correctly react on errors: it return a JSON answer instead of HTML page. Error pages also now return adjusted HTTP code (404 or 500). - The LSurl system have been adjust to handle API mode : - On declaring handlers, we could now specify if it's an API view with new $api_mode paremeter of add_handler() method - The LSurlRequest object have a new attribute to check if it's an API request - The error_404() method handle the API mode to return JSON answer. Furthermore, if no handlers matched with the requested URL, API mode is automatically enabled if the requested URL starts with 'api/'. - LSform implement it own API mode flag and a new submited flag that be toggle via the new setSubmited() method. Some major changes also occured on LSformElement classes to specifically handle API input/output for each types of attributes: - a new getApiValue() method permit to retrieve the API value of the attribute (on show API view) - the getPostData() method now have to correctly handle API input for the attribute (on create/modify API views). A programmatic way have been adopted for each types of attributes. - The LSimport and LScli create/modify commands also evolved to enable API mode of the LSform. This permit to take advantage of the new capability of LSform/LSformElement to handle input values with a programmatic way. - New routes have been add to handle API views. All this new routes start with 'api/1.0/' and use the same URL schema as the web UI. The API currently permit to search/show/add/modify/remove LSobjects and manages their relations.
2021-02-03 14:40:28 +01:00
}
/**
* Set API mode
*
* @param boolean $val True to enable API mode (optional, default: true)
Add API feature Some major changes have been made to handle this new feature : - LSsession now have a flag about API mode. The displayTemplate() and displayAjaxReturn() methods have been adjust to correctly handle this mode. - LSauth system have been adjust to handle a custom API mode : - LSauthMethod can support or not this mode : the $api_mode_supported permit to defined if supported (default, false). Currently, only HTTP (default in API mode) and annonymous mode support it. - An api_access parameter permit to configure witch type of user LSobject types could use the API. This flag must be set to True to allow a type of LSobject (default: False). In a same way, a web_access parameter now permit to disable Web access for some types of users (but this parameter is optional and its default value is True). - The HTTP method is the privileged first method for API mode. In this mode, if auth data aren't present in environment, it will request it by triggered a 403 HTTP error. Realm can be configured with new LSAUTHMETHOD_HTTP_API_REALM constant. - The LStemplate system handle API mode to correctly react on errors: it return a JSON answer instead of HTML page. Error pages also now return adjusted HTTP code (404 or 500). - The LSurl system have been adjust to handle API mode : - On declaring handlers, we could now specify if it's an API view with new $api_mode paremeter of add_handler() method - The LSurlRequest object have a new attribute to check if it's an API request - The error_404() method handle the API mode to return JSON answer. Furthermore, if no handlers matched with the requested URL, API mode is automatically enabled if the requested URL starts with 'api/'. - LSform implement it own API mode flag and a new submited flag that be toggle via the new setSubmited() method. Some major changes also occured on LSformElement classes to specifically handle API input/output for each types of attributes: - a new getApiValue() method permit to retrieve the API value of the attribute (on show API view) - the getPostData() method now have to correctly handle API input for the attribute (on create/modify API views). A programmatic way have been adopted for each types of attributes. - The LSimport and LScli create/modify commands also evolved to enable API mode of the LSform. This permit to take advantage of the new capability of LSform/LSformElement to handle input values with a programmatic way. - New routes have been add to handle API views. All this new routes start with 'api/1.0/' and use the same URL schema as the web UI. The API currently permit to search/show/add/modify/remove LSobjects and manages their relations.
2021-02-03 14:40:28 +01:00
*
* @return void
Add API feature Some major changes have been made to handle this new feature : - LSsession now have a flag about API mode. The displayTemplate() and displayAjaxReturn() methods have been adjust to correctly handle this mode. - LSauth system have been adjust to handle a custom API mode : - LSauthMethod can support or not this mode : the $api_mode_supported permit to defined if supported (default, false). Currently, only HTTP (default in API mode) and annonymous mode support it. - An api_access parameter permit to configure witch type of user LSobject types could use the API. This flag must be set to True to allow a type of LSobject (default: False). In a same way, a web_access parameter now permit to disable Web access for some types of users (but this parameter is optional and its default value is True). - The HTTP method is the privileged first method for API mode. In this mode, if auth data aren't present in environment, it will request it by triggered a 403 HTTP error. Realm can be configured with new LSAUTHMETHOD_HTTP_API_REALM constant. - The LStemplate system handle API mode to correctly react on errors: it return a JSON answer instead of HTML page. Error pages also now return adjusted HTTP code (404 or 500). - The LSurl system have been adjust to handle API mode : - On declaring handlers, we could now specify if it's an API view with new $api_mode paremeter of add_handler() method - The LSurlRequest object have a new attribute to check if it's an API request - The error_404() method handle the API mode to return JSON answer. Furthermore, if no handlers matched with the requested URL, API mode is automatically enabled if the requested URL starts with 'api/'. - LSform implement it own API mode flag and a new submited flag that be toggle via the new setSubmited() method. Some major changes also occured on LSformElement classes to specifically handle API input/output for each types of attributes: - a new getApiValue() method permit to retrieve the API value of the attribute (on show API view) - the getPostData() method now have to correctly handle API input for the attribute (on create/modify API views). A programmatic way have been adopted for each types of attributes. - The LSimport and LScli create/modify commands also evolved to enable API mode of the LSform. This permit to take advantage of the new capability of LSform/LSformElement to handle input values with a programmatic way. - New routes have been add to handle API views. All this new routes start with 'api/1.0/' and use the same URL schema as the web UI. The API currently permit to search/show/add/modify/remove LSobjects and manages their relations.
2021-02-03 14:40:28 +01:00
*/
public static function setApiMode($val=true) {
self :: $api_mode = (boolean)$val;
self :: setAjaxDisplay(self :: $api_mode);
}
2020-04-29 15:54:21 +02:00
/**
2021-08-25 18:02:37 +02:00
* Fetch builded template
*
* @param string $template The template file to build
* @param array $variables Template variables to set before building
2020-04-29 15:54:21 +02:00
*
* @return string The template builded HTML code
*/
public static function fetchTemplate($template,$variables=array()) {
foreach($variables as $name => $val) {
LStemplate :: assign($name,$val);
}
return LStemplate :: fetch($template);
}
2020-04-29 15:54:21 +02:00
/**
*
2021-08-25 18:02:37 +02:00
* Takes an array of LSobject and reduce it using a search filter on
* another type of LSobject.
*
* If an error is present in the filter definition array, an empty
* array is returned.
*
* @param string $LSobject The default LSobject type
* @param array<LSldapObject> $set Array of LSobjects
* @param array $filter_def Definition of the search filter for reduction
* @param string|null $basedn Base DN for search, null by default
*
* @return array The reduced array of LSobjects
*/
private static function reduceLdapSet($LSobject, $set, $filter_def, $basedn=null) {
if (empty($set)) {
return array();
}
if (! isset($filter_def['filter']) &&
(! isset($filter_def['attr']) ||
! isset($filter_def['attr_value']))) {
2020-05-08 15:51:21 +02:00
self :: log_debug("reduceLdapSet(): LSobject LSprofil filter invalid : " . varDump($filter_def));
return array();
}
2020-05-08 15:51:21 +02:00
self :: log_debug('reduceLdapSet(): reducing set of');
foreach ($set as $object) {
LSdebug('LSsession :: -> ' . $object -> getDn());
}
$LSobject = isset($filter_def['LSObject']) ? $filter_def['LSobject'] : $LSobject;
2020-05-08 15:51:21 +02:00
self :: log_debug('reduceLdapSet(): LSobject = ' . $LSobject);
$filters = array();
foreach ($set as $object) {
if (isset($filter_def['filter'])) {
$filters[] = $object -> getFData($filter_def['filter']);
}
else {
$value = $object -> getFData($filter_def['attr_value']);
$filters[] = Net_LDAP2_Filter::create($filter_def['attr'], 'equals', $value);
}
}
$filter = LSldap::combineFilters('or', $filters);
$params = array(
'basedn' => isset($filter_def['basedn']) ? self :: getLSuserObject() -> getFData($filter_def['basedn']) : $basedn,
'filter' => $filter,
'onlyAccessible' => False
);
if (isset($filter_def['params']) && is_array($filter_def['params'])) {
$params = array_merge($filter_def['params'],$params);
}
$LSsearch = new LSsearch($LSobject,'LSsession :: loadLSprofiles',$params,true);
$LSsearch -> run(false);
$set = $LSsearch -> listObjects();
2020-05-08 15:51:21 +02:00
self :: log_debug('reduceLdapSet(): reduced set to');
foreach ($set as $object) {
2020-05-08 15:51:21 +02:00
self :: log_debug('reduceLdapSet(): -> ' . $object -> getDn());
}
return $set;
}
/**
2021-08-25 18:02:37 +02:00
* Loading user's profiles: load profile on specific LSobject type
*
* Regarding configuration, user profile on specific list on the specified
* LSobject type will be loaded.
*
* @param string $profile The LSprofile
* @param string $LSobject The LSobject type
* @param array $listInfos The parameters to list of granted objects
*
* @return void
*/
private static function loadLSprofilesLSobjects($profile, $LSobject, $listInfos) {
if (! self :: loadLSclass('LSsearch')) {
2020-05-08 15:51:21 +02:00
self :: log_error('Fail to load class LSsearch');
return;
}
# we are gonna grow a set of objects progressively, we start from the user
$set = array(self :: getLSuserObject());
$basedn = isset($listInfos['basedn']) ? self :: getLSuserObject() -> getFData($listInfos['basedn']) : null;
$LSobject = isset($listInfos['LSobject']) ? $listInfos['LSobject'] : $LSobject;
if (isset($listInfos['filters']) && is_array($listInfos['filters'])) {
foreach ($listInfos['filters'] as $filter_def) {
$set = self :: reduceLdapSet($LSobject, $set, $filter_def, $basedn);
}
}
if (isset($listInfos['filter']) || (isset($listInfos['attr']) && isset($listInfos['attr_value']))) {
# support legacy profile definition
$set = self :: reduceLdapSet($LSobject, $set, $listInfos, $basedn);
}
$DNs = [];
foreach ($set as $object) {
$DNs[] = $object -> getDn();
}
if (!isset(self :: $LSprofiles[$profile])) {
self :: $LSprofiles[$profile]=$DNs;
}
else {
foreach($DNs as $dn) {
if (!in_array($dn,self :: $LSprofiles[$profile])) {
self :: $LSprofiles[$profile][] = $dn;
}
}
}
}
/**
2021-08-25 18:02:37 +02:00
* Loading user's profiles
2020-04-29 15:54:21 +02:00
*
* @return boolean True on success, false otherwise
**/
private static function loadLSprofiles() {
if (!is_array(self :: $ldapServer['LSprofiles'])) {
self :: log_warning('loadLSprofiles(): Current LDAP server have no configured LSprofile.');
return false;
}
self :: log_trace("loadLSprofiles(): Current LDAP server LSprofile configuration: ".varDump(self :: $ldapServer['LSprofiles']));
self :: $LSprofiles = array();
foreach (self :: $ldapServer['LSprofiles'] as $profile => $profileInfos) {
if (!is_array($profileInfos)) {
self :: log_warning("loadLSprofiles(): Invalid configuration for LSprofile '$profile' (must be an array).");
continue;
}
foreach ($profileInfos as $topDn => $rightsInfos) {
// Do not handle 'label' key as a topDn
if ($topDn == 'label') {
continue;
}
elseif ($topDn == 'LSobjects') {
/*
* If $topDn == 'LSobject', we search for each LSobject type to find
* all items on witch the user will have powers.
*/
if (!is_array($rightsInfos)) {
self :: log_warning('loadLSprofiles(): LSobjects => [] must be an array');
continue;
}
foreach ($rightsInfos as $LSobject => $listInfos) {
self :: log_debug('loadLSprofiles(): loading LSprofile ' . $profile . ' for LSobject ' . $LSobject . ' with params ' . var_export($listInfos, true));
self :: loadLSprofilesLSobjects($profile, $LSobject, $listInfos);
}
}
else {
/*
* Otherwise, we are normally in case of $topDn == a base DN and
* $rightsInfos is :
* - an array (see above)
* - a user DN
*/
if (is_array($rightsInfos)) {
- LdapSaisie : J'ai commencé à écrire la docummentation de LdapSaisie que j'espère pour voir bientôt ajouté au SVN. Cela me fait mettre le doit sur quelques problèmes de nommages, d'organisation que j'ai corrigé sur le fait : - Concepte de level était enfaite celui de subDn : seule le nom subDn doit rester. - Le concept de LSrights dans LSsession et config.inc.php était mal nommé. Il correspond plus à la définition de LSprofile en réalité. Je l'ai renommé ainsi. - Les paramètres authobject et authobject_pwdattr n'étaient pas très représentatif. Je les ai renommé en authObjectType et authObjectTypeAttrPwd. - Templates : -> Correction du template default dans le but de changer la couleur bleu dominante juger trop flashy :). Au passage j'ai dégagé l'image de fond de #main utilisé pour colorer le menu : cette méthode est moche et quitte a à faire du moche je préfère utiliser un vulgaire tableau que des bidouille de ce genre. -> Création d'un logo pour LdapSaisie qui vient remplacer le logo Easter-Eggs utilisé jusqu'alors. -> Ajout d'un favicon. - LSerror : -> J'ai déplacé les definitions de code d'erreur dans le contexte concerné (càd dans les fichiers de définition des classes) (Feature Request #1757) -> J'en ai profité pour renommer les codes d'erreur avec un prefixe pour eviter les doublons -> J'ai donc modifié une grande partie des fichiers pour changer les codes erreurs utilisés -> Ajout d'une méthode getError() utilisé par getErrors() -> Modification de la méthode stop() - LSformElement_password : - Correction d'un bug dans la génération des mots de passe dans un formulaire de création d'objet. - Ajout d'une possiblité de choisir le type de hashage du mot de passe stocké dans l'annuaire (Feature Request #1756) - Traduction des commentaires - LSattribute : Ajout des vérifications dans les méthodes de la classe lors de l'utilisation des objets html et ldap. - LSsession : -> Renforcement des méthodes faisant des inclusions d'autres fichiers php.
2009-01-02 17:00:25 +01:00
/*
* $rightsInfos is an array, so we could have :
* - users DNs as key and null as value
* - DN of an object as key and an array of parameters to list users from one
* of its attribute as value
- LdapSaisie : J'ai commencé à écrire la docummentation de LdapSaisie que j'espère pour voir bientôt ajouté au SVN. Cela me fait mettre le doit sur quelques problèmes de nommages, d'organisation que j'ai corrigé sur le fait : - Concepte de level était enfaite celui de subDn : seule le nom subDn doit rester. - Le concept de LSrights dans LSsession et config.inc.php était mal nommé. Il correspond plus à la définition de LSprofile en réalité. Je l'ai renommé ainsi. - Les paramètres authobject et authobject_pwdattr n'étaient pas très représentatif. Je les ai renommé en authObjectType et authObjectTypeAttrPwd. - Templates : -> Correction du template default dans le but de changer la couleur bleu dominante juger trop flashy :). Au passage j'ai dégagé l'image de fond de #main utilisé pour colorer le menu : cette méthode est moche et quitte a à faire du moche je préfère utiliser un vulgaire tableau que des bidouille de ce genre. -> Création d'un logo pour LdapSaisie qui vient remplacer le logo Easter-Eggs utilisé jusqu'alors. -> Ajout d'un favicon. - LSerror : -> J'ai déplacé les definitions de code d'erreur dans le contexte concerné (càd dans les fichiers de définition des classes) (Feature Request #1757) -> J'en ai profité pour renommer les codes d'erreur avec un prefixe pour eviter les doublons -> J'ai donc modifié une grande partie des fichiers pour changer les codes erreurs utilisés -> Ajout d'une méthode getError() utilisé par getErrors() -> Modification de la méthode stop() - LSformElement_password : - Correction d'un bug dans la génération des mots de passe dans un formulaire de création d'objet. - Ajout d'une possiblité de choisir le type de hashage du mot de passe stocké dans l'annuaire (Feature Request #1756) - Traduction des commentaires - LSattribute : Ajout des vérifications dans les méthodes de la classe lors de l'utilisation des objets html et ldap. - LSsession : -> Renforcement des méthodes faisant des inclusions d'autres fichiers php.
2009-01-02 17:00:25 +01:00
*/
foreach($rightsInfos as $dn => $conf) {
if (is_array($conf) && isset($conf['attr']) && isset($conf['LSobject'])) {
2021-08-25 18:02:37 +02:00
// We have to retrieve this LSobject and list one of its attribute to retrieve
// users key info.
if(!self :: loadLSobject($conf['LSobject'])) {
// Warning log message is already emited by self :: loadLSobject()
continue;
}
2021-08-25 18:02:37 +02:00
// Instanciate object and retrieve its data
$object = new $conf['LSobject']();
if (!$object -> loadData($dn)) {
self :: log_warning("loadLSprofiles(): fail to load DN '$dn'.");
continue;
}
2021-08-25 18:02:37 +02:00
// Retrieve users key info values from object attribute
$list_users_key_values = $object -> getValue($conf['attr']);
if (!is_array($list_users_key_values)) {
2021-08-25 18:02:37 +02:00
self :: log_warning("loadLSprofiles(): fail to retrieve values of attribute '".$conf['attr']."' of LSobject ".$conf['LSobject']." with DN='$dn'");
continue;
}
2021-08-25 18:02:37 +02:00
self :: log_trace("loadLSprofiles(): retrieved values of attribute '".$conf['attr']."' of LSobject ".$conf['LSobject']." with DN='$dn': '".implode("', '", $list_users_key_values)."'");
2021-08-25 18:02:37 +02:00
// Retrieve current connected key value
$user_key_value_format = (isset($conf['attr_value'])?$conf['attr_value']:'%{dn}');
$user_key_value = self :: getLSuserObject() -> getFData($user_key_value_format);
// Check current connected user is list in attribute values
if (in_array($user_key_value, $list_users_key_values)) {
self :: log_trace("loadLSprofiles(): current connected user is present in attribute '".$conf['attr']."' of LSobject ".$conf['LSobject']." with DN='$dn' (user key value: '$user_key_value')");
self :: $LSprofiles[$profile][] = $topDn;
}
else
self :: log_trace("loadLSprofiles(): current connected user is not list in attribute '".$conf['attr']."' of LSobject ".$conf['LSobject']." with DN='$dn' (user key value: '$user_key_value')");
}
else {
// $conf is not an array, users DNs could be the key $dn and we don't care
// about $conf value (normally null)
if (self :: $dn == $dn) {
self :: log_trace("loadLSprofiles(): current connected user DN is explicitly list in $profile LSprofile configuration");
self :: $LSprofiles[$profile][] = $topDn;
}
else
self :: log_trace("loadLSprofiles(): current connected user DN is NOT explicitly list in $profile LSprofile configuration");
}
}
}
else {
// $rightsInfos is not an array => its could be a user DN
if ( self :: $dn == $rightsInfos ) {
self :: log_trace("loadLSprofiles(): current connected user DN is explicitly appointed as $profile LSprofile in configuration");
self :: $LSprofiles[$profile][] = $topDn;
}
else
self :: log_trace("loadLSprofiles(): current connected user DN is NOT explicitly appointed as $profile LSprofile in configuration");
}
} // fin else ($topDn == 'LSobjects' or 'label')
} // fin foreach($profileInfos)
} // fin foreach LSprofiles
self :: log_debug("loadLSprofiles(): LSprofiles = ".print_r(self :: $LSprofiles,1));
return true;
}
2020-04-29 15:54:21 +02:00
/**
2021-08-25 18:02:37 +02:00
* Load user access rights to build interface menu
*
* @return void
*/
private static function loadLSaccess() {
$LSaccess=array();
if (isset(self :: $ldapServer['subDn']) && is_array(self :: $ldapServer['subDn'])) {
foreach(self :: $ldapServer['subDn'] as $name => $config) {
if ($name=='LSobject') {
if (is_array($config)) {
2020-04-29 15:54:21 +02:00
// Définition des subDns
foreach($config as $objectType => $objectConf) {
if (self :: loadLSobject($objectType)) {
if ($subdnobject = new $objectType()) {
$tbl = $subdnobject -> getSelectArray(NULL,self::getRootDn(),NULL,NULL,false,NULL,array('onlyAccessible' => False));
if (is_array($tbl)) {
// Définition des accès
$access=array();
if (is_array($objectConf['LSobjects'])) {
foreach($objectConf['LSobjects'] as $type) {
if (self :: loadLSobject($type)) {
if (self :: canAccess($type)) {
$access[$type] = LSconfig :: get('LSobjects.'.$type.'.label');
}
}
}
}
foreach($tbl as $dn => $dn_name) {
$LSaccess[$dn]=$access;
}
}
}
}
}
}
}
else {
if ((isCompatibleDNs(self :: $ldapServer['ldap_config']['basedn'],$config['dn']))&&($config['dn']!='')) {
$access=array();
if (is_array($config['LSobjects'])) {
foreach($config['LSobjects'] as $objectType) {
if (self :: loadLSobject($objectType)) {
if (self :: canAccess($objectType)) {
$access[$objectType] = LSconfig :: get('LSobjects.'.$objectType.'.label');
}
}
}
}
$LSaccess[$config['dn']]=$access;
}
}
}
}
else {
if(is_array(self :: $ldapServer['LSaccess'])) {
$access=array();
foreach(self :: $ldapServer['LSaccess'] as $objectType) {
if (self :: loadLSobject($objectType)) {
if (self :: canAccess($objectType))
$access[$objectType] = $objectType :: getLabel();
else
self :: log_debug("loadLSaccess(): authenticated user have no access to $objectType");
}
}
$LSaccess[self :: getTopDn()] = $access;
}
}
if (LSauth :: displaySelfAccess()) {
foreach($LSaccess as $dn => $access) {
$LSaccess[$dn] = array_merge(
array(
'SELF' => 'My account'
),
$access
);
}
}
self :: $LSaccess = $LSaccess;
$_SESSION['LSsession']['LSaccess'] = $LSaccess;
}
2015-08-21 17:51:52 +02:00
/**
* Get user access
*
* @param string|null $topDn Top DN (optional, default : current)
*
* @return array User's access
**/
public static function getLSaccess($topDn=null) {
if (is_null($topDn)) $topDn = self :: getTopDn();
if (isset(self :: $LSaccess[$topDn])) {
return self :: $LSaccess[$topDn];
}
return array();
}
2015-08-21 17:51:52 +02:00
/**
* Load user access to LSaddons views
*
* @return void
2015-08-21 17:51:52 +02:00
*/
private static function loadLSaddonsViewsAccess() {
$LSaddonsViewsAccess=array();
foreach (self :: $LSaddonsViews as $addon => $conf) {
foreach ($conf as $viewId => $viewConf) {
if (self :: canAccessLSaddonView($addon,$viewId)) {
2018-09-13 18:36:45 +02:00
$LSaddonsViewsAccess["$addon::$viewId"]=array (
2015-08-21 17:51:52 +02:00
'LSaddon' => $addon,
'id' => $viewId,
'label' => $viewConf['label'],
'showInMenu' => $viewConf['showInMenu']
2015-08-21 17:51:52 +02:00
);
}
}
}
self :: $LSaddonsViewsAccess = $LSaddonsViewsAccess;
$_SESSION['LSsession']['LSaddonsViewsAccess'] = $LSaddonsViewsAccess;
}
/**
2021-08-25 18:02:37 +02:00
* Check if user is a specified profile on specified DN
*
* @param string $dn DN of the object to check
* @param string $profile The profile
*
* @return boolean True if user is a specified profile on specified DN, false otherwise.
*/
public static function isLSprofile($dn,$profile) {
if (is_array(self :: $LSprofiles[$profile])) {
foreach(self :: $LSprofiles[$profile] as $topDn) {
if($dn == $topDn) {
return true;
}
else if ( isCompatibleDNs($dn,$topDn) ) {
return true;
}
}
}
return false;
}
/**
2021-08-25 18:02:37 +02:00
* Check if user is at least one of specified profiles on specified DN
*
* @param string $dn DN of the object to check
* @param array<string> $profiles The profiles list
*
* @return boolean True if user is at least one of specified profiles on specified DN, false otherwise.
*/
public static function isLSprofiles($dn,$profiles) {
foreach ($profiles as $profile) {
if (self :: isLSprofile($dn,$profile))
return true;
}
return false;
}
2020-04-29 15:54:21 +02:00
/**
* Return connected user's LSprofiles on a specific object.
*
* @param string $dn The object's DN
2020-04-29 15:54:21 +02:00
*
* @return array Array of LSprofiles of the connected user on the specified object
*/
public static function whoami($dn) {
$retval = array('user');
2020-04-29 15:54:21 +02:00
if (self :: $LSuserObjectType)
$retval[] = self :: $LSuserObjectType;
foreach(self :: $LSprofiles as $profile => $infos) {
if(self :: isLSprofile($dn, $profile)) {
$retval[] = $profile;
self :: log_trace("whoami($dn): is '$profile'");
}
else
self :: log_trace("whoami($dn): is NOT '$profile'");
}
2020-04-29 15:54:21 +02:00
if (self :: $dn == $dn) {
$retval[] = 'self';
}
2020-04-29 15:54:21 +02:00
self :: log_trace("whoami($dn): '".implode("', '", $retval)."'");
return $retval;
}
2020-04-29 15:54:21 +02:00
/**
* Return user access right to access to specify LSobject
2020-04-29 15:54:21 +02:00
*
* @param string $LSobject The LSobject type
* @param string|null $dn The LSobject DN (optional, default: the container_dn of the LSobject type)
* @param string|null $right The requested access right ('r' or 'w', optional, default: 'r' or 'w')
* @param string|null $attr The requested attribute name (optional, default: any)
*
* @return boolean True is user can access to the specify LSobject, False otherwise
*/
public static function canAccess($LSobject, $dn=NULL, $right=NULL, $attr=NULL) {
if (!self :: loadLSobject($LSobject)) {
return false;
}
// Access always granted in CLI mode
if (php_sapi_name() == "cli")
return true;
if ($dn) {
$whoami = self :: whoami($dn);
if ($dn == self :: getLSuserObject() -> getValue('dn')) {
if (!self :: in_menu('SELF')) {
self :: log_trace("canAccess('$LSobject', '$dn', '$right', '$attr'): SELF not in menu");
return false;
}
}
else {
$obj = new $LSobject();
$obj -> dn = $dn;
- LSsearch/LSsearchEntry : Added a new classes to doing and exploit ldap object search -> view/select => change to use it (php+template+js) -> LSattr_html_select_object/LSattr_html_select_list => change to use it -> LSldapObject : -> change listObjectsName() / searchObject() / getSelectArray() / listObjects() -> comment search() function -> Add triggers to clean cache -> LSpeople : Update search config -> LSsession : Change function to use it : - getSubDnLdapServer() - loadLSprofiles() - LSrelation : Deplace error codes declaration from LSsession in class file - LSldapObject : -> change getObjectFilter() / getLabel() / getSubDnValue() / getSubDnName() for can call then staticaly -> Add afterModify() function and trigger -> Change getObjectFilter() / listObjectsInRelation() to use Net_LDAP2_Filter -> Add __get() function -> Move one LSerror code for LSrelation function from LSsession class file -> Add a global variable to save cached data ($cache) -> Change subDn and subDnName access methods - LSauth : Move LSsession auth procedure in a dedicated class -> LSsession : Change startLSsession() to use it - LSsession : -> Add getRootDn() function -> Fix getTopDn() to return root DN if no topDn is currently defined -> Create dedicated functions to support recoveryPassword mecanism : - recoverPasswd() - recoverPasswdSendMail() - recoverPasswdFirstStep() - recoverPasswdSecondStep -> Customize LSdebug return and display (php+js) -> Clean unused error codes -> Move LSrelation error codes -> Comment ajax method
2009-10-30 01:03:17 +01:00
if (!self :: in_menu($LSobject,$obj -> subDnValue)) {
self :: log_trace("canAccess('$LSobject', '$dn', '$right', '$attr'): $LSobject (for subDN='".$obj -> subDnValue."') not in menu");
return false;
}
}
}
else {
$objectdn=LSconfig :: get('LSobjects.'.$LSobject.'.container_dn').','.self :: getTopDn();
self :: log_trace("canAccess('$LSobject', '$dn', '$right', '$attr'): use object $LSobject container DN => '$objectdn'");
$whoami = self :: whoami($objectdn);
}
2020-04-29 15:54:21 +02:00
2021-08-25 18:02:37 +02:00
// On specific attribute
if ($attr) {
if ($attr=='rdn') {
$attr=LSconfig :: get('LSobjects.'.$LSobject.'.rdn');
self :: log_trace("canAccess('$LSobject', '$dn', '$right', 'rdn'): RDN attribute = $attr");
}
if (!is_array(LSconfig :: get('LSobjects.'.$LSobject.'.attrs.'.$attr))) {
self :: log_warning("canAccess('$LSobject', '$dn', '$right', '$attr'): Attribute '$attr' doesn't exists");
return false;
}
$r = 'n';
foreach($whoami as $who) {
$nr = LSconfig :: get('LSobjects.'.$LSobject.'.attrs.'.$attr.'.rights.'.$who);
if($nr == 'w') {
self :: log_trace("canAccess('$LSobject', '$dn', '$right', '$attr'): grant WRITE access via LSprofile '$who'.");
$r = 'w';
}
else if($nr == 'r') {
if ($r=='n') {
self :: log_trace("canAccess('$LSobject', '$dn', '$right', '$attr'): grant READ access via LSprofile '$who'.");
$r='r';
}
}
}
self :: log_trace("canAccess($LSobject,$dn,$right,$attr): right detected = '$r'");
2020-04-29 15:54:21 +02:00
if ($right == 'r' || $right=='w')
return self :: checkRight($right, $r);
return ($r == 'r' || $r == 'w');
}
2020-04-29 15:54:21 +02:00
2021-08-25 18:02:37 +02:00
// On any attributes
$attrs_conf=LSconfig :: get('LSobjects.'.$LSobject.'.attrs');
if (is_array($attrs_conf)) {
if (($right=='r')||($right=='w')) {
foreach($whoami as $who) {
foreach ($attrs_conf as $attr_name => $attr_config) {
if (isset($attr_config['rights'][$who]) && self :: checkRight($right, $attr_config['rights'][$who])) {
return true;
}
}
}
}
else {
foreach($whoami as $who) {
foreach ($attrs_conf as $attr_name => $attr_config) {
if ( (isset($attr_config['rights'][$who])) && ( ($attr_config['rights'][$who]=='r') || ($attr_config['rights'][$who]=='w') ) ) {
return true;
}
}
}
}
}
return false;
}
2020-04-29 15:54:21 +02:00
/**
* Check a requested right against maximum right of a user
* @param string $requested The requested right
* @param string $authorized The authorized maximum right
* @return boolean
*/
public static function checkRight($requested, $authorized) {
if ($requested == $authorized)
return true;
if ($requested == 'r' && $authorized == 'w')
return true;
return false;
}
/**
2021-08-25 18:02:37 +02:00
* Check if user can edit a specified object
2020-04-29 15:54:21 +02:00
*
* @param string $LSobject The LSobject type
* @param string|null $dn The DN of the object (optional, default: the container_dn of the LSobject type)
* @param string|null $attr The attribue name of attribute to check (optional, default: any attributes)
*
* @return boolean True if user is granted, false otherwise
*/
2021-08-25 18:02:37 +02:00
public static function canEdit($LSobject, $dn=NULL, $attr=NULL) {
return self :: canAccess($LSobject, $dn, 'w', $attr);
}
/**
2021-08-25 18:02:37 +02:00
* Check if user can remove a specified object
2020-04-29 15:54:21 +02:00
*
* @param string $LSobject The LSobject type
* @param string $dn The DN of the object (optional, default: the container_dn of the LSobject type)
*
* @return boolean True if user is granted, false otherwise
2020-04-29 15:54:21 +02:00
*/
2021-08-25 18:02:37 +02:00
public static function canRemove($LSobject, $dn) {
return self :: canAccess($LSobject, $dn, 'w', 'rdn');
}
2020-04-29 15:54:21 +02:00
/**
2021-08-25 18:02:37 +02:00
* Check if user can create a specific object type
2020-04-29 15:54:21 +02:00
*
* @param string $LSobject The LSobject type
*
* @return boolean True if user is granted, false otherwise
2020-04-29 15:54:21 +02:00
*/
public static function canCreate($LSobject) {
if (!self :: loadLSobject($LSobject)) {
return false;
}
if (LSconfig :: get("LSobjects.$LSobject.disable_creation")) {
return false;
}
return self :: canAccess($LSobject,NULL,'w','rdn');
}
2020-04-29 15:54:21 +02:00
Add API feature Some major changes have been made to handle this new feature : - LSsession now have a flag about API mode. The displayTemplate() and displayAjaxReturn() methods have been adjust to correctly handle this mode. - LSauth system have been adjust to handle a custom API mode : - LSauthMethod can support or not this mode : the $api_mode_supported permit to defined if supported (default, false). Currently, only HTTP (default in API mode) and annonymous mode support it. - An api_access parameter permit to configure witch type of user LSobject types could use the API. This flag must be set to True to allow a type of LSobject (default: False). In a same way, a web_access parameter now permit to disable Web access for some types of users (but this parameter is optional and its default value is True). - The HTTP method is the privileged first method for API mode. In this mode, if auth data aren't present in environment, it will request it by triggered a 403 HTTP error. Realm can be configured with new LSAUTHMETHOD_HTTP_API_REALM constant. - The LStemplate system handle API mode to correctly react on errors: it return a JSON answer instead of HTML page. Error pages also now return adjusted HTTP code (404 or 500). - The LSurl system have been adjust to handle API mode : - On declaring handlers, we could now specify if it's an API view with new $api_mode paremeter of add_handler() method - The LSurlRequest object have a new attribute to check if it's an API request - The error_404() method handle the API mode to return JSON answer. Furthermore, if no handlers matched with the requested URL, API mode is automatically enabled if the requested URL starts with 'api/'. - LSform implement it own API mode flag and a new submited flag that be toggle via the new setSubmited() method. Some major changes also occured on LSformElement classes to specifically handle API input/output for each types of attributes: - a new getApiValue() method permit to retrieve the API value of the attribute (on show API view) - the getPostData() method now have to correctly handle API input for the attribute (on create/modify API views). A programmatic way have been adopted for each types of attributes. - The LSimport and LScli create/modify commands also evolved to enable API mode of the LSform. This permit to take advantage of the new capability of LSform/LSformElement to handle input values with a programmatic way. - New routes have been add to handle API views. All this new routes start with 'api/1.0/' and use the same URL schema as the web UI. The API currently permit to search/show/add/modify/remove LSobjects and manages their relations.
2021-02-03 14:40:28 +01:00
/**
* Check user right to compute the result of a LSformat
*
* @param string $LSformat The LSformat string to check
* @param string $LSobject The LSobject type
* @param string|null $dn The LSobject DN (optional, default: the container_dn of the LSobject type)
Add API feature Some major changes have been made to handle this new feature : - LSsession now have a flag about API mode. The displayTemplate() and displayAjaxReturn() methods have been adjust to correctly handle this mode. - LSauth system have been adjust to handle a custom API mode : - LSauthMethod can support or not this mode : the $api_mode_supported permit to defined if supported (default, false). Currently, only HTTP (default in API mode) and annonymous mode support it. - An api_access parameter permit to configure witch type of user LSobject types could use the API. This flag must be set to True to allow a type of LSobject (default: False). In a same way, a web_access parameter now permit to disable Web access for some types of users (but this parameter is optional and its default value is True). - The HTTP method is the privileged first method for API mode. In this mode, if auth data aren't present in environment, it will request it by triggered a 403 HTTP error. Realm can be configured with new LSAUTHMETHOD_HTTP_API_REALM constant. - The LStemplate system handle API mode to correctly react on errors: it return a JSON answer instead of HTML page. Error pages also now return adjusted HTTP code (404 or 500). - The LSurl system have been adjust to handle API mode : - On declaring handlers, we could now specify if it's an API view with new $api_mode paremeter of add_handler() method - The LSurlRequest object have a new attribute to check if it's an API request - The error_404() method handle the API mode to return JSON answer. Furthermore, if no handlers matched with the requested URL, API mode is automatically enabled if the requested URL starts with 'api/'. - LSform implement it own API mode flag and a new submited flag that be toggle via the new setSubmited() method. Some major changes also occured on LSformElement classes to specifically handle API input/output for each types of attributes: - a new getApiValue() method permit to retrieve the API value of the attribute (on show API view) - the getPostData() method now have to correctly handle API input for the attribute (on create/modify API views). A programmatic way have been adopted for each types of attributes. - The LSimport and LScli create/modify commands also evolved to enable API mode of the LSform. This permit to take advantage of the new capability of LSform/LSformElement to handle input values with a programmatic way. - New routes have been add to handle API views. All this new routes start with 'api/1.0/' and use the same URL schema as the web UI. The API currently permit to search/show/add/modify/remove LSobjects and manages their relations.
2021-02-03 14:40:28 +01:00
*
* @return boolean True is user can compute the result of the LSformat, False otherwise
Add API feature Some major changes have been made to handle this new feature : - LSsession now have a flag about API mode. The displayTemplate() and displayAjaxReturn() methods have been adjust to correctly handle this mode. - LSauth system have been adjust to handle a custom API mode : - LSauthMethod can support or not this mode : the $api_mode_supported permit to defined if supported (default, false). Currently, only HTTP (default in API mode) and annonymous mode support it. - An api_access parameter permit to configure witch type of user LSobject types could use the API. This flag must be set to True to allow a type of LSobject (default: False). In a same way, a web_access parameter now permit to disable Web access for some types of users (but this parameter is optional and its default value is True). - The HTTP method is the privileged first method for API mode. In this mode, if auth data aren't present in environment, it will request it by triggered a 403 HTTP error. Realm can be configured with new LSAUTHMETHOD_HTTP_API_REALM constant. - The LStemplate system handle API mode to correctly react on errors: it return a JSON answer instead of HTML page. Error pages also now return adjusted HTTP code (404 or 500). - The LSurl system have been adjust to handle API mode : - On declaring handlers, we could now specify if it's an API view with new $api_mode paremeter of add_handler() method - The LSurlRequest object have a new attribute to check if it's an API request - The error_404() method handle the API mode to return JSON answer. Furthermore, if no handlers matched with the requested URL, API mode is automatically enabled if the requested URL starts with 'api/'. - LSform implement it own API mode flag and a new submited flag that be toggle via the new setSubmited() method. Some major changes also occured on LSformElement classes to specifically handle API input/output for each types of attributes: - a new getApiValue() method permit to retrieve the API value of the attribute (on show API view) - the getPostData() method now have to correctly handle API input for the attribute (on create/modify API views). A programmatic way have been adopted for each types of attributes. - The LSimport and LScli create/modify commands also evolved to enable API mode of the LSform. This permit to take advantage of the new capability of LSform/LSformElement to handle input values with a programmatic way. - New routes have been add to handle API views. All this new routes start with 'api/1.0/' and use the same URL schema as the web UI. The API currently permit to search/show/add/modify/remove LSobjects and manages their relations.
2021-02-03 14:40:28 +01:00
*/
public static function canComputeLSformat($LSformat, $LSobject, $dn=NULL) {
foreach (getFieldInFormat($LSformat) as $attr)
if (!self :: canAccess($LSobject, $dn, 'r', $attr))
return false;
return true;
}
/**
2021-08-25 18:02:37 +02:00
* Check user right to manage a specified relation of specified object
2020-04-29 15:54:21 +02:00
*
* @param string $dn The LSobject DN (optional, default: the container_dn of the LSobject type)
* @param string $LSobject The LSobject type
* @param string $relationName The relation name of the object
* @param string|null $right The right to check (possible values: 'r' or 'w', optional, default: any)
*
* @return boolean True if user is granted, false otherwise
*/
public static function relationCanAccess($dn,$LSobject,$relationName,$right=NULL) {
$relConf=LSconfig :: get('LSobjects.'.$LSobject.'.LSrelation.'.$relationName);
if (!is_array($relConf)) {
self :: log_trace("relationCanAccess($dn,$LSobject,$relationName,$right): unknown relation");
return false;
}
// Access always granted in CLI mode
if (php_sapi_name() == "cli")
return true;
$whoami = self :: whoami($dn);
self :: log_trace("relationCanAccess($dn,$LSobject,$relationName,$right): whoami = ".varDump($whoami));
if (($right=='w') || ($right=='r')) {
$r = 'n';
foreach($whoami as $who) {
$nr = ((isset($relConf['rights'][$who]))?$relConf['rights'][$who]:'');
if($nr == 'w') {
self :: log_trace("relationCanAccess($dn,$LSobject,$relationName,$right): grant WRITE access via LSprofile '$who'.");
$r = 'w';
}
else if($nr == 'r') {
if ($r=='n') {
self :: log_trace("relationCanAccess($dn,$LSobject,$relationName,$right): grant READ access via LSprofile '$who'.");
$r='r';
}
}
}
self :: log_trace("relationCanAccess($dn,$LSobject,$relationName,$right): right detected = '$r'");
2020-04-29 15:54:21 +02:00
if (self :: checkRight($right, $r)) {
return true;
}
}
else {
foreach($whoami as $who) {
if ((isset($relConf['rights'][$who])) && ( ($relConf['rights'][$who] == 'w') || ($relConf['rights'][$who] == 'r') ) ) {
self :: log_trace("relationCanAccess($dn,$LSobject,$relationName,$right): granted via LSprofile '$who'.");
return true;
}
}
}
return false;
}
/**
2021-08-25 18:02:37 +02:00
* Check user right to edit a specified relation of specified object
2020-04-29 15:54:21 +02:00
*
* @param string $dn The LSobject DN (optional, default: the container_dn of the LSobject type)
* @param string $LSobject The LSobject type
* @param string $relationName The relation name of the object
*
* @return boolean True if user is granted, false otherwise
2020-04-29 15:54:21 +02:00
*/
2021-08-25 18:02:37 +02:00
public static function relationCanEdit($dn, $LSobject, $relationName) {
return self :: relationCanAccess($dn, $LSobject, $relationName, 'w');
}
2011-03-25 18:05:26 +01:00
/**
2021-08-25 18:02:37 +02:00
* Check user right to execute a customAction on specified object
2020-04-29 15:54:21 +02:00
*
* @param string $dn The LSobject DN
* @param string $LSobject The LSobject type
* @param string $customActionName The customAction name
2011-03-25 18:05:26 +01:00
*
* @return boolean True if user is granted, false otherwise
2011-03-25 18:05:26 +01:00
*/
2021-08-25 18:02:37 +02:00
public static function canExecuteCustomAction($dn, $LSobject, $customActionName) {
2011-03-25 18:05:26 +01:00
$conf=LSconfig :: get('LSobjects.'.$LSobject.'.customActions.'.$customActionName);
if (!is_array($conf))
return false;
// Access always granted in CLI mode
if (php_sapi_name() == "cli")
return true;
2011-03-25 18:05:26 +01:00
$whoami = self :: whoami($dn);
if (isset($conf['rights']) && is_array($conf['rights'])) {
if ($dn == self :: $dn && in_array('self', $conf['rights']))
return True;
2011-03-25 18:05:26 +01:00
foreach($whoami as $who) {
if ($who != 'self' && in_array($who,$conf['rights'])) {
2011-03-25 18:05:26 +01:00
return True;
}
}
}
2020-04-29 15:54:21 +02:00
return false;
2011-03-25 18:05:26 +01:00
}
2014-10-08 17:24:30 +02:00
/**
2021-08-25 18:02:37 +02:00
* Check user right to execute a customAction on a specifed search
2014-10-08 17:24:30 +02:00
*
* @param LSsearch $LSsearch The LSsearch search
* @param string $customActionName The customAction name
2014-10-08 17:24:30 +02:00
*
* @return boolean True if user is granted, false otherwise
2014-10-08 17:24:30 +02:00
*/
public static function canExecuteLSsearchCustomAction($LSsearch,$customActionName) {
$conf=LSconfig :: get('LSobjects.'.$LSsearch -> LSobject.'.LSsearch.customActions.'.$customActionName);
if (!is_array($conf))
return false;
// Access always granted in CLI mode
if (php_sapi_name() == "cli")
return true;
2014-10-08 17:24:30 +02:00
$dn=$LSsearch -> basedn;
if (is_null($dn)) $dn=self::getTopDn();
$whoami = self :: whoami($dn);
if (isset($conf['rights']) && is_array($conf['rights'])) {
foreach($whoami as $who) {
if (in_array($who,$conf['rights'])) {
return True;
}
}
}
return false;
2014-10-08 17:24:30 +02:00
}
2015-08-21 17:51:52 +02:00
/**
* Return user right to access to a LSaddon view
*
* @param string $LSaddon The LSaddon
* @param string $viewId The LSaddon view ID
2015-08-21 17:51:52 +02:00
*
* @return boolean True if user is granted, false otherwise
2015-08-21 17:51:52 +02:00
*/
public static function canAccessLSaddonView($LSaddon,$viewId) {
if (self :: loadLSaddon($LSaddon)) {
if (!isset(self :: $LSaddonsViews[$LSaddon]) || !isset(self :: $LSaddonsViews[$LSaddon][$viewId]))
return false;
if (!is_array(self :: $LSaddonsViews[$LSaddon][$viewId]['allowedLSprofiles'])) {
return true;
}
$whoami = self :: whoami(self :: getTopDn());
2015-08-21 17:51:52 +02:00
if (isset(self :: $LSaddonsViews[$LSaddon][$viewId]['allowedLSprofiles']) && is_array(self :: $LSaddonsViews[$LSaddon][$viewId]['allowedLSprofiles'])) {
2015-08-21 17:51:52 +02:00
foreach($whoami as $who) {
if (in_array($who,self :: $LSaddonsViews[$LSaddon][$viewId]['allowedLSprofiles'])) {
return True;
}
}
}
}
return false;
2015-08-21 17:51:52 +02:00
}
/**
2021-08-25 18:02:37 +02:00
* Add a temporary file that stored a specifed value
2020-04-29 15:54:21 +02:00
*
* @param mixed $value The value stored in the temporary file
* @param string $filePath The temporary file path
* @author Benjamin Renard <brenard@easter-eggs.com>
2020-04-29 15:54:21 +02:00
*
* @return void
**/
2021-08-25 18:02:37 +02:00
public static function addTmpFile($value, $filePath) {
$hash = mhash(MHASH_MD5,$value);
self :: $tmp_file[$filePath] = $hash;
$_SESSION['LSsession']['tmp_file'][$filePath] = $hash;
}
2020-04-29 15:54:21 +02:00
/**
2021-08-25 18:02:37 +02:00
* Return the path of a temporary file that store the specified value (is exists)
2020-04-29 15:54:21 +02:00
*
* @author Benjamin Renard <brenard@easter-eggs.com>
2020-04-29 15:54:21 +02:00
*
* @param mixed $value The value stored in the temporary file
2020-04-29 15:54:21 +02:00
*
* @return string|false The temporary file path if exists, False otherwise
**/
public static function tmpFileExist($value) {
$hash = mhash(MHASH_MD5,$value);
foreach(self :: $tmp_file as $filePath => $contentHash) {
if ($hash == $contentHash) {
return $filePath;
}
}
return false;
}
2020-04-29 15:54:21 +02:00
/**
2021-08-25 18:02:37 +02:00
* Return the path of a temporary file that store the specified value
2020-04-29 15:54:21 +02:00
*
2021-08-25 18:02:37 +02:00
* The temporary file will be created if not already exists.
2020-04-29 15:54:21 +02:00
*
* @author Benjamin Renard <brenard@easter-eggs.com>
2020-04-29 15:54:21 +02:00
*
* @param mixed $value The value to store in the temporary file
2020-04-29 15:54:21 +02:00
*
* @return string|false The path of the temporary file, false in case of error
**/
public static function getTmpFile($value) {
2021-08-25 18:02:37 +02:00
$path = self :: tmpFileExist($value);
if (!$path) {
$path = LS_TMP_DIR_PATH .rand().'.tmp';
$fp = fopen($path, "w");
fwrite($fp, $value);
fclose($fp);
2021-08-25 18:02:37 +02:00
self :: addTmpFile($value, $path);
}
2021-08-25 18:02:37 +02:00
return $path;
}
2020-04-29 15:15:41 +02:00
/**
2021-08-25 18:02:37 +02:00
* Return the URL of a temporary file that store the specified value
2020-04-29 15:15:41 +02:00
*
2021-08-25 18:02:37 +02:00
* The temporary file will be created if not already exists.
2020-04-29 15:15:41 +02:00
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @param mixed $value The value to store in the temporary file
2020-04-29 15:15:41 +02:00
*
* @return string|false The URL of the temporary file, false in case of error
2020-04-29 15:15:41 +02:00
**/
public static function getTmpFileURL($value) {
$path = self :: getTmpFile($value);
if ($path && is_file($path))
return "tmp/".basename($path);
2020-04-29 15:15:41 +02:00
return False;
}
/**
2021-08-25 18:02:37 +02:00
* Return the path of a temporary file specified by its filename (if exists)
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @param string $filename The filename
*
* @return string|false The path of the temporary file if found, false otherwise
**/
public static function getTmpFileByFilename($filename) {
foreach(self :: $tmp_file as $filePath => $contentHash) {
if (basename($filePath) == $filename) {
return $filePath;
}
}
return False;
}
/**
2021-08-25 18:02:37 +02:00
* Delete one or all temporary files
2020-04-29 15:54:21 +02:00
*
* @author Benjamin Renard <brenard@easter-eggs.com>
2020-04-29 15:54:21 +02:00
*
* @param string|null $filePath A specific temporary file path to delete
2021-08-25 18:02:37 +02:00
* (optional, default: all temporary files wil be deleted)
*
* @return void
**/
public static function deleteTmpFile($filePath=NULL) {
if ($filePath) {
@unlink($filePath);
unset(self :: $tmp_file[$filePath]);
unset($_SESSION['LSsession']['tmp_file'][$filePath]);
}
else {
foreach(self :: $tmp_file as $file => $content) {
@unlink($file);
}
self :: $tmp_file = array();
$_SESSION['LSsession']['tmp_file'] = array();
}
}
/**
2021-08-25 18:02:37 +02:00
* Check if LSprofiles cache is enabled
*
* @author Benjamin Renard <brenard@easter-eggs.com>
2020-04-29 15:54:21 +02:00
*
* @return boolean True if LSprofiles cache is enabled, false otherwise.
*/
public static function cacheLSprofiles() {
return LSconfig :: get(
'cacheLSprofiles',
LSconfig :: get('cacheLSprofiles', false, 'bool'), // Default
'bool',
self :: $ldapServer
);
}
/**
2021-08-25 18:02:37 +02:00
* Check if subDn cache is enabled
*
* @author Benjamin Renard <brenard@easter-eggs.com>
2020-04-29 15:54:21 +02:00
*
* @return boolean True if subDn cache is enabled, false otherwise.
*/
public static function cacheSudDn() {
return LSconfig :: get(
'cacheSubDn',
LSconfig :: get('cacheSubDn', false, 'bool'), // Default
'bool',
self :: $ldapServer
);
}
2020-04-29 15:54:21 +02:00
/**
2021-08-25 18:02:37 +02:00
* Check if searchs cache is enabled
*
* @author Benjamin Renard <brenard@easter-eggs.com>
2020-04-29 15:54:21 +02:00
*
* @return boolean True if searchs cache is enabled, false otherwise.
*/
public static function cacheSearch() {
return LSconfig :: get(
'cacheSearch',
LSconfig :: get('cacheSearch', false, 'bool'), // Default
'bool',
self :: $ldapServer
);
}
2019-05-21 12:06:24 +02:00
/**
2021-08-25 18:02:37 +02:00
* Check if global search is enabled
2019-05-21 12:06:24 +02:00
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*
* @return boolean True if global search is enabled, false instead
2019-05-21 12:06:24 +02:00
*/
public static function globalSearch() {
return LSconfig :: get(
'globalSearch',
LSconfig :: get('globalSearch', true, 'bool'), // Default
'bool',
self :: $ldapServer
);
2019-05-21 12:06:24 +02:00
}
/**
2021-08-25 18:02:37 +02:00
* Retrieve label of current LDAP server subDn
*
* Note: the label is returned untranslated.
2020-04-29 15:54:21 +02:00
*
* @author Benjamin Renard <brenard@easter-eggs.com>
2020-04-29 15:54:21 +02:00
*
* @return string The label of current LDAP server subDn
*/
public static function getSubDnLabel() {
return __(
LSconfig :: get(
'subDnLabel',
___('Level'), // default value (to translate)
'string',
self :: $ldapServer
)
);
}
2020-04-29 15:54:21 +02:00
/**
2021-08-25 18:02:37 +02:00
* Return the name of a specifed subDn
2020-04-29 15:54:21 +02:00
*
* @param string|false $subDn The subDn (optional, default: the current one)
2020-04-29 15:54:21 +02:00
*
* @return string The name of the current subDn if found or an empty string otherwise
*/
public static function getSubDnName($subDn=false) {
if (!$subDn) {
$subDn = self :: getTopDn();
}
$subDns = self :: getSubDnLdapServer(false);
if (is_array($subDns)) {
if (isset($subDns[$subDn])) {
return $subDns[$subDn];
}
}
return '';
}
/**
2021-08-25 18:02:37 +02:00
* Check if object type is used to list current LDAP server subDns
2020-04-29 15:54:21 +02:00
*
* @param string $type The LSobject type
2020-04-29 15:54:21 +02:00
*
* @return boolean True if specified object type is used to list current LDAP server subDns, false otherwise
*/
public static function isSubDnLSobject($type) {
$result = false;
if (isset(self :: $ldapServer['subDn']['LSobject']) && is_array(self :: $ldapServer['subDn']['LSobject'])) {
foreach(self :: $ldapServer['subDn']['LSobject'] as $key => $value) {
if ($key==$type) {
$result=true;
}
}
}
return $result;
}
2020-04-29 15:54:21 +02:00
/**
2021-08-25 18:02:37 +02:00
* Check if specified LSobject type is in current interface menu
2020-04-29 15:54:21 +02:00
*
* @param string $LSobject The LSobject type
* @param string|null $topDn The topDn to check (optional, default: current one)
2021-08-25 18:02:37 +02:00
*
* @return boolean True if specified LSobject type is in current interface menu, false otherwise
*/
2021-08-25 18:02:37 +02:00
public static function in_menu($LSobject, $topDn=NULL) {
if (!$topDn) {
$topDn = self :: getTopDn();
}
return isset(self :: $LSaccess[$topDn][$LSobject]);
}
2020-04-29 15:54:21 +02:00
/**
2021-08-25 18:02:37 +02:00
* Check if current LDAP server have subDns
2020-04-29 15:54:21 +02:00
*
* @return boolean True if current LDAP server have subDns, false otherwise
*/
public static function haveSubDn() {
return (isset(self :: $ldapServer['subDn']) && is_array(self :: $ldapServer['subDn']));
}
/**
2021-08-25 18:02:37 +02:00
* Add an information to display to user (on next displayed page or in API result)
2020-04-29 15:54:21 +02:00
*
* @param string $msg The message
2020-04-29 15:54:21 +02:00
*
* @return void
*/
public static function addInfo($msg) {
$_SESSION['LSsession_infos'][]=$msg;
}
2020-04-29 15:54:21 +02:00
/**
* Redirect user to another URL
2020-04-29 15:54:21 +02:00
*
* /!\ DEPRECATED /!\ : please use LSurl :: redirect()
*
* @param string $url The destination URL
* @param boolean $exit Unsed (keep for reto-compatibility)
2020-04-29 15:54:21 +02:00
*
* @return void
2020-04-29 15:54:21 +02:00
*/
public static function redirect($url, $exit=true) {
LSerror :: addErrorCode(
'LSsession_27',
array(
'old' => 'LSsession :: redirect()',
'new' => 'LSurl :: redirect()',
'context' => LSlog :: get_debug_backtrace_context(),
)
);
LSurl :: redirect($url);
}
2020-04-29 15:54:21 +02:00
- LSview : ajout de input hidden pour contenir les informations du type et du DN de l'objet affiché. - LSmail : Ajout d'une fonctionalité d'envoie de mail depuis l'interface. -> Modification de LSformElement_mail pour utiliser cette fonctionalité -> Agrémentation du fichier index_ajax.php -> Ajout d'un LSaddons :: mail - LSsession : -> Ajout d'une méthode getEmailSender() -> Utilisation de la méthode getEmailSender() pour la partie de récupération de mot de passe -> Revue des méthodes loadLSaddon() et loadLSaddons() - LSconfirmBox : -> Ajout de binding onClose() et onCancel() - LSsmoothbox : -> Déport de la creation de la structure dans la méthode build() -> Suppression du principe de refreshElement au profit de binding sur les évenements onClose, onValid et onCancel -> Ajout des méthodes addEvent() et fireEvent() -> Suppression de la méthode setRefreshElement() -> Ajout de la méthode asNew() pour remettre l'objet dans son état d'origine pour l'utilisation simultané de l'objet par plusieurs autres -> Vérification lors du clique sur le closeBtn qu'une précédente confirmBox n'est pas déjà ouvert -> La méthode close() ne fait plus que fermer la LSsmoothbox et les méthodes valid() et cancel() gère les cas de fermeture et lance la méthode close() -> Ajout de la méthode openHTML() pour l'ouverture de la LSsmoothbox avec un code HTML passé en paramètre -> Ajout de la méthode setOption() - LSrelation & LSformElement_select_object : -> Utilisation du principe d'évenement de la LSsmoothbox plutôt que du refreshElement -> Utilisation de la méthode asNew() pour eviter tout problème de concurence - LSdefault : Ajout de la méthode displayInfos()
2008-09-25 17:15:33 +02:00
/**
2021-08-25 18:02:37 +02:00
* Return the sender email address configured for the current LDAP server
2020-04-29 15:54:21 +02:00
*
* @return string The sender email address (if configured), false otherwise
- LSview : ajout de input hidden pour contenir les informations du type et du DN de l'objet affiché. - LSmail : Ajout d'une fonctionalité d'envoie de mail depuis l'interface. -> Modification de LSformElement_mail pour utiliser cette fonctionalité -> Agrémentation du fichier index_ajax.php -> Ajout d'un LSaddons :: mail - LSsession : -> Ajout d'une méthode getEmailSender() -> Utilisation de la méthode getEmailSender() pour la partie de récupération de mot de passe -> Revue des méthodes loadLSaddon() et loadLSaddons() - LSconfirmBox : -> Ajout de binding onClose() et onCancel() - LSsmoothbox : -> Déport de la creation de la structure dans la méthode build() -> Suppression du principe de refreshElement au profit de binding sur les évenements onClose, onValid et onCancel -> Ajout des méthodes addEvent() et fireEvent() -> Suppression de la méthode setRefreshElement() -> Ajout de la méthode asNew() pour remettre l'objet dans son état d'origine pour l'utilisation simultané de l'objet par plusieurs autres -> Vérification lors du clique sur le closeBtn qu'une précédente confirmBox n'est pas déjà ouvert -> La méthode close() ne fait plus que fermer la LSsmoothbox et les méthodes valid() et cancel() gère les cas de fermeture et lance la méthode close() -> Ajout de la méthode openHTML() pour l'ouverture de la LSsmoothbox avec un code HTML passé en paramètre -> Ajout de la méthode setOption() - LSrelation & LSformElement_select_object : -> Utilisation du principe d'évenement de la LSsmoothbox plutôt que du refreshElement -> Utilisation de la méthode asNew() pour eviter tout problème de concurence - LSdefault : Ajout de la méthode displayInfos()
2008-09-25 17:15:33 +02:00
*/
public static function getEmailSender() {
2021-08-25 18:02:37 +02:00
return (
is_array(self :: $ldapServer) && isset(self :: $ldapServer['emailSender']) && self :: $ldapServer['emailSender']?
self :: $ldapServer['emailSender']:
null
);
- LSview : ajout de input hidden pour contenir les informations du type et du DN de l'objet affiché. - LSmail : Ajout d'une fonctionalité d'envoie de mail depuis l'interface. -> Modification de LSformElement_mail pour utiliser cette fonctionalité -> Agrémentation du fichier index_ajax.php -> Ajout d'un LSaddons :: mail - LSsession : -> Ajout d'une méthode getEmailSender() -> Utilisation de la méthode getEmailSender() pour la partie de récupération de mot de passe -> Revue des méthodes loadLSaddon() et loadLSaddons() - LSconfirmBox : -> Ajout de binding onClose() et onCancel() - LSsmoothbox : -> Déport de la creation de la structure dans la méthode build() -> Suppression du principe de refreshElement au profit de binding sur les évenements onClose, onValid et onCancel -> Ajout des méthodes addEvent() et fireEvent() -> Suppression de la méthode setRefreshElement() -> Ajout de la méthode asNew() pour remettre l'objet dans son état d'origine pour l'utilisation simultané de l'objet par plusieurs autres -> Vérification lors du clique sur le closeBtn qu'une précédente confirmBox n'est pas déjà ouvert -> La méthode close() ne fait plus que fermer la LSsmoothbox et les méthodes valid() et cancel() gère les cas de fermeture et lance la méthode close() -> Ajout de la méthode openHTML() pour l'ouverture de la LSsmoothbox avec un code HTML passé en paramètre -> Ajout de la méthode setOption() - LSrelation & LSformElement_select_object : -> Utilisation du principe d'évenement de la LSsmoothbox plutôt que du refreshElement -> Utilisation de la méthode asNew() pour eviter tout problème de concurence - LSdefault : Ajout de la méthode displayInfos()
2008-09-25 17:15:33 +02:00
}
2018-09-13 18:36:45 +02:00
/**
* Redirect to default view (if defined)
*
* @return void
2018-09-13 18:36:45 +02:00
*/
public static function redirectToDefaultView($force=false) {
if (isset(self :: $ldapServer['defaultView'])) {
if (array_key_exists(self :: $ldapServer['defaultView'], self :: $LSaccess[self :: getTopDn()])) {
2020-05-03 18:48:33 +02:00
LSurl :: redirect('object/'.self :: $ldapServer['defaultView']);
2018-09-13 18:36:45 +02:00
}
elseif (array_key_exists(self :: $ldapServer['defaultView'], self :: $LSaddonsViewsAccess)) {
$addon = self :: $LSaddonsViewsAccess[self :: $ldapServer['defaultView']];
2020-05-03 18:48:33 +02:00
LSurl :: redirect('addon/'.urlencode(self :: $LSaddonsViewsAccess[self :: $ldapServer['defaultView']]['LSaddon'])."/".urlencode(self :: $LSaddonsViewsAccess[self :: $ldapServer['defaultView']]['id']));
2018-09-13 18:36:45 +02:00
}
}
if ($force)
LSurl :: redirect();
2018-09-13 18:36:45 +02:00
}
2020-04-29 15:54:21 +02:00
/**
* Add help info
2020-04-29 15:54:21 +02:00
*
* @param string $group The group name of this information
* @param array $info Array of the information to add (name => value)
2020-04-29 15:54:21 +02:00
*
* @return void
*/
public static function addHelpInfos($group, $info) {
LStemplate :: addHelpInfo($group, $info);
LSerror :: addErrorCode(
'LSsession_27',
array(
'old' => 'LStemplate :: addHelpInfo()',
'new' => 'LStemplate :: addHelpInfo()',
'context' => LSlog :: get_debug_backtrace_context(),
)
);
}
2020-04-29 15:54:21 +02:00
/**
2021-08-25 18:02:37 +02:00
* Define error codes relative to LSsession PHP class
*
* Note: could not be directly defined after PHP class declaration (like in othe class files)
* because LSerror is not already loaded and initialized. It's done on self :: startLSerror().
2020-04-29 15:54:21 +02:00
*
* @return void
2020-04-29 15:54:21 +02:00
*/
private static function defineLSerrors() {
/*
* Error Codes
*/
LSerror :: defineError('LSsession_01',
2020-09-03 18:31:53 +02:00
___("LSsession : The constant '%{const}' is not defined.")
);
LSerror :: defineError('LSsession_02',
2020-09-03 18:31:53 +02:00
___("LSsession : The addon '%{addon}' support is uncertain. Verify system compatibility and the add-on configuration.")
);
LSerror :: defineError('LSsession_03',
___("LSsession : LDAP server's configuration data are invalid. Can't connect.")
);
LSerror :: defineError('LSsession_04',
2020-09-03 18:31:53 +02:00
___("LSsession : Failed to load LSobject type '%{type}' : unknon type.")
);
LSerror :: defineError('LSsession_05',
2020-09-03 18:31:53 +02:00
___("LSsession : Failed to load LSclass '%{class}'.")
);
LSerror :: defineError('LSsession_06',
___("LSsession : Login or password incorrect.")
);
LSerror :: defineError('LSsession_07',
___("LSsession : Impossible to identify you : Duplication of identities.")
);
LSerror :: defineError('LSsession_08',
___("LSsession : Can't load class of authentification (%{class}).")
);
LSerror :: defineError('LSsession_09',
___("LSsession : Can't connect to LDAP server.")
);
LSerror :: defineError('LSsession_10',
___("LSsession : Impossible to authenticate you.")
);
LSerror :: defineError('LSsession_11',
___("LSsession : Your are not authorized to do this action.")
);
LSerror :: defineError('LSsession_12',
___("LSsession : Some informations are missing to display this page.")
);
2011-03-25 18:05:26 +01:00
LSerror :: defineError('LSsession_13',
___("LSsession : The function '%{function}' of the custom action '%{customAction}' does not exists or is not configured.")
2011-03-25 18:05:26 +01:00
);
LSerror :: defineError('LSsession_14',
2021-08-25 18:02:37 +02:00
___("LSsession : Fail to retrieve user's LDAP credentials from LSauth.")
);
LSerror :: defineError('LSsession_15',
___("LSsession : Fail to reconnect to LDAP server with user's LDAP credentials.")
);
2015-07-30 16:37:42 +02:00
LSerror :: defineError('LSsession_16',
___("LSsession : No import/export format define for this object type.")
2015-07-30 16:37:42 +02:00
);
LSerror :: defineError('LSsession_17',
___("LSsession : Error during creation of list of levels. Contact administrators. (Code : %{code})")
);
LSerror :: defineError('LSsession_18',
___("LSsession : The password recovery is disabled for this LDAP server.")
);
LSerror :: defineError('LSsession_19',
___("LSsession : Some informations are missing to recover your password. Contact administrators.")
);
LSerror :: defineError('LSsession_20',
___("LSsession : Error during password recovery. Contact administrators.(Step : %{step})")
);
LSerror :: defineError('LSsession_21',
2020-09-03 18:31:53 +02:00
___("LSsession : The function '%{func}' configured for the view '%{view}' of the LSaddon '%{addon}' is not declared in the LSaddon file.")
);
LSerror :: defineError('LSsession_22',
___("LSsession : Failed to load resource file '%{file}'.")
);
2015-08-21 17:51:52 +02:00
LSerror :: defineError('LSsession_23',
2020-09-03 18:31:53 +02:00
___("LSsession : The function '%{func}' configured for the view '%{view}' of the LSaddon '%{addon}' doesn't exist.")
2015-08-21 17:51:52 +02:00
);
2017-08-02 12:00:11 +02:00
LSerror :: defineError('LSsession_24',
___("LSsession : invalid related object's DN pass in parameter.")
2017-08-02 12:00:11 +02:00
);
2020-05-02 18:32:31 +02:00
LSerror :: defineError('LSsession_25',
___("LSsession : the LSaddon %{addon} keep using old-style addon view URL. Please upgrade it.")
2020-05-02 18:32:31 +02:00
);
2020-05-03 18:48:33 +02:00
LSerror :: defineError('LSsession_26',
___("LSsession : You have been redirect from an old-style URL %{url}. Please upgrade this link.")
2020-05-03 18:48:33 +02:00
);
LSerror :: defineError('LSsession_27',
___("LSsession : You always seem to use %{old} in your custom code: Please upgrade it and use %{new}.<pre>\nContext:\n%{context}</pre>")
);
}
- LSmail : Création d'une classe PHP gérant les dépendances d'affichage et les requêtes Ajax. - LSrelation : - Création d'une classe PHP gérant les dépendances d'affichage et les requêtes Ajax. - Modification du JS pour faire appels à ces méthodes - La méthode displayInLSview() remplace le bloc du fichier view.php pour l'affichage des relations d'un objet. - Internationalisation. - LSselect : Création d'une classe PHP gérant les dépendances d'affichage et les requêtes Ajax. - LSformElement_password : - Ajout de méthodes statiques gérant les appels Ajax. - Modification du JS pour faire appels à ces méthodes - LSformElement_select_object : - Ajout de méthodes statiques gérant les appels Ajax. - Modification du JS pour faire appels à ces méthodes - LSformElement_mail : Utilisation des nouvelles fonctionnalités pour gérer les dépendances. - LSformElement_image : Utilisation des nouvelles fonctionnalités pour gérer les dépendances. - LSsession : - Ajout de méthodes statiques gérant les appels Ajax des formulaires de login et de recupération de mot de passe. - Modification des JS pour faire appels à ces méthodes - Ajout d'un mécanisme permettant de garder la session PHP active - Modification de LSdefault.js pour gérer ce mécanisme - LSform : - Ajout de méthodes statiques gérant les appels Ajax des formulaires - Ajout de la méthode loadDependenciesDisplayView() gérant les dépendances d'affichage d'une LSview. - Utilisation des nouvelles fonctionnalités pour gérer les dépendances. - view.php / modify.php /select.php : Utilisation des nouvelles fonctionnalités pour gérer les dépendances et les LSrelations. - LSview : Modification de l'internationnalisation.
2009-02-20 15:05:22 +01:00
- LSsearch/LSsearchEntry : Added a new classes to doing and exploit ldap object search -> view/select => change to use it (php+template+js) -> LSattr_html_select_object/LSattr_html_select_list => change to use it -> LSldapObject : -> change listObjectsName() / searchObject() / getSelectArray() / listObjects() -> comment search() function -> Add triggers to clean cache -> LSpeople : Update search config -> LSsession : Change function to use it : - getSubDnLdapServer() - loadLSprofiles() - LSrelation : Deplace error codes declaration from LSsession in class file - LSldapObject : -> change getObjectFilter() / getLabel() / getSubDnValue() / getSubDnName() for can call then staticaly -> Add afterModify() function and trigger -> Change getObjectFilter() / listObjectsInRelation() to use Net_LDAP2_Filter -> Add __get() function -> Move one LSerror code for LSrelation function from LSsession class file -> Add a global variable to save cached data ($cache) -> Change subDn and subDnName access methods - LSauth : Move LSsession auth procedure in a dedicated class -> LSsession : Change startLSsession() to use it - LSsession : -> Add getRootDn() function -> Fix getTopDn() to return root DN if no topDn is currently defined -> Create dedicated functions to support recoveryPassword mecanism : - recoverPasswd() - recoverPasswdSendMail() - recoverPasswdFirstStep() - recoverPasswdSecondStep -> Customize LSdebug return and display (php+js) -> Clean unused error codes -> Move LSrelation error codes -> Comment ajax method
2009-10-30 01:03:17 +01:00
/**
* Ajax method when change ldapserver on login/recoveryPassword form
2020-04-29 15:54:21 +02:00
*
* @param array &$data The return data address
2020-04-29 15:54:21 +02:00
*
* @return void
- LSsearch/LSsearchEntry : Added a new classes to doing and exploit ldap object search -> view/select => change to use it (php+template+js) -> LSattr_html_select_object/LSattr_html_select_list => change to use it -> LSldapObject : -> change listObjectsName() / searchObject() / getSelectArray() / listObjects() -> comment search() function -> Add triggers to clean cache -> LSpeople : Update search config -> LSsession : Change function to use it : - getSubDnLdapServer() - loadLSprofiles() - LSrelation : Deplace error codes declaration from LSsession in class file - LSldapObject : -> change getObjectFilter() / getLabel() / getSubDnValue() / getSubDnName() for can call then staticaly -> Add afterModify() function and trigger -> Change getObjectFilter() / listObjectsInRelation() to use Net_LDAP2_Filter -> Add __get() function -> Move one LSerror code for LSrelation function from LSsession class file -> Add a global variable to save cached data ($cache) -> Change subDn and subDnName access methods - LSauth : Move LSsession auth procedure in a dedicated class -> LSsession : Change startLSsession() to use it - LSsession : -> Add getRootDn() function -> Fix getTopDn() to return root DN if no topDn is currently defined -> Create dedicated functions to support recoveryPassword mecanism : - recoverPasswd() - recoverPasswdSendMail() - recoverPasswdFirstStep() - recoverPasswdSecondStep -> Customize LSdebug return and display (php+js) -> Clean unused error codes -> Move LSrelation error codes -> Comment ajax method
2009-10-30 01:03:17 +01:00
**/
2020-04-29 15:54:21 +02:00
public static function ajax_onLdapServerChangedLogin(&$data) {
- LSmail : Création d'une classe PHP gérant les dépendances d'affichage et les requêtes Ajax. - LSrelation : - Création d'une classe PHP gérant les dépendances d'affichage et les requêtes Ajax. - Modification du JS pour faire appels à ces méthodes - La méthode displayInLSview() remplace le bloc du fichier view.php pour l'affichage des relations d'un objet. - Internationalisation. - LSselect : Création d'une classe PHP gérant les dépendances d'affichage et les requêtes Ajax. - LSformElement_password : - Ajout de méthodes statiques gérant les appels Ajax. - Modification du JS pour faire appels à ces méthodes - LSformElement_select_object : - Ajout de méthodes statiques gérant les appels Ajax. - Modification du JS pour faire appels à ces méthodes - LSformElement_mail : Utilisation des nouvelles fonctionnalités pour gérer les dépendances. - LSformElement_image : Utilisation des nouvelles fonctionnalités pour gérer les dépendances. - LSsession : - Ajout de méthodes statiques gérant les appels Ajax des formulaires de login et de recupération de mot de passe. - Modification des JS pour faire appels à ces méthodes - Ajout d'un mécanisme permettant de garder la session PHP active - Modification de LSdefault.js pour gérer ce mécanisme - LSform : - Ajout de méthodes statiques gérant les appels Ajax des formulaires - Ajout de la méthode loadDependenciesDisplayView() gérant les dépendances d'affichage d'une LSview. - Utilisation des nouvelles fonctionnalités pour gérer les dépendances. - view.php / modify.php /select.php : Utilisation des nouvelles fonctionnalités pour gérer les dépendances et les LSrelations. - LSview : Modification de l'internationnalisation.
2009-02-20 15:05:22 +01:00
if ( isset($_REQUEST['server']) ) {
self :: setLdapServer($_REQUEST['server']);
$data = array();
if ( self :: LSldapConnect() ) {
if (session_id()=="") session_start();
- LSmail : Création d'une classe PHP gérant les dépendances d'affichage et les requêtes Ajax. - LSrelation : - Création d'une classe PHP gérant les dépendances d'affichage et les requêtes Ajax. - Modification du JS pour faire appels à ces méthodes - La méthode displayInLSview() remplace le bloc du fichier view.php pour l'affichage des relations d'un objet. - Internationalisation. - LSselect : Création d'une classe PHP gérant les dépendances d'affichage et les requêtes Ajax. - LSformElement_password : - Ajout de méthodes statiques gérant les appels Ajax. - Modification du JS pour faire appels à ces méthodes - LSformElement_select_object : - Ajout de méthodes statiques gérant les appels Ajax. - Modification du JS pour faire appels à ces méthodes - LSformElement_mail : Utilisation des nouvelles fonctionnalités pour gérer les dépendances. - LSformElement_image : Utilisation des nouvelles fonctionnalités pour gérer les dépendances. - LSsession : - Ajout de méthodes statiques gérant les appels Ajax des formulaires de login et de recupération de mot de passe. - Modification des JS pour faire appels à ces méthodes - Ajout d'un mécanisme permettant de garder la session PHP active - Modification de LSdefault.js pour gérer ce mécanisme - LSform : - Ajout de méthodes statiques gérant les appels Ajax des formulaires - Ajout de la méthode loadDependenciesDisplayView() gérant les dépendances d'affichage d'une LSview. - Utilisation des nouvelles fonctionnalités pour gérer les dépendances. - view.php / modify.php /select.php : Utilisation des nouvelles fonctionnalités pour gérer les dépendances et les LSrelations. - LSview : Modification de l'internationnalisation.
2009-02-20 15:05:22 +01:00
if (isset($_SESSION['LSsession_topDn'])) {
$sel = $_SESSION['LSsession_topDn'];
}
else {
$sel = NULL;
}
$list = self :: getSubDnLdapServerOptions($sel,true);
- LSmail : Création d'une classe PHP gérant les dépendances d'affichage et les requêtes Ajax. - LSrelation : - Création d'une classe PHP gérant les dépendances d'affichage et les requêtes Ajax. - Modification du JS pour faire appels à ces méthodes - La méthode displayInLSview() remplace le bloc du fichier view.php pour l'affichage des relations d'un objet. - Internationalisation. - LSselect : Création d'une classe PHP gérant les dépendances d'affichage et les requêtes Ajax. - LSformElement_password : - Ajout de méthodes statiques gérant les appels Ajax. - Modification du JS pour faire appels à ces méthodes - LSformElement_select_object : - Ajout de méthodes statiques gérant les appels Ajax. - Modification du JS pour faire appels à ces méthodes - LSformElement_mail : Utilisation des nouvelles fonctionnalités pour gérer les dépendances. - LSformElement_image : Utilisation des nouvelles fonctionnalités pour gérer les dépendances. - LSsession : - Ajout de méthodes statiques gérant les appels Ajax des formulaires de login et de recupération de mot de passe. - Modification des JS pour faire appels à ces méthodes - Ajout d'un mécanisme permettant de garder la session PHP active - Modification de LSdefault.js pour gérer ce mécanisme - LSform : - Ajout de méthodes statiques gérant les appels Ajax des formulaires - Ajout de la méthode loadDependenciesDisplayView() gérant les dépendances d'affichage d'une LSview. - Utilisation des nouvelles fonctionnalités pour gérer les dépendances. - view.php / modify.php /select.php : Utilisation des nouvelles fonctionnalités pour gérer les dépendances et les LSrelations. - LSview : Modification de l'internationnalisation.
2009-02-20 15:05:22 +01:00
if (is_string($list)) {
$data['list_topDn'] = "<select name='LSsession_topDn' id='LSsession_topDn'>".$list."</select>";
$data['subDnLabel'] = self :: getSubDnLabel();
}
}
$data['recoverPassword'] = isset(self :: $ldapServer['recoverPassword']);
}
}
2020-04-29 15:54:21 +02:00
2015-08-21 17:50:31 +02:00
/**
* Set globals from the ldap server
*
* @return void
2015-08-21 17:50:31 +02:00
*/
public static function setGlobals() {
if ( isset(self :: $ldapServer['globals'])) {
foreach(self :: $ldapServer['globals'] as $key => $value) {
$GLOBALS[$key] = $value;
}
}
}
2015-08-21 17:51:52 +02:00
/**
* Register a LSaddon view
*
* @param string $LSaddon The LSaddon
* @param string $viewId The view ID
* @param string $label The view's label
* @param callable $viewFunction The view's function name
* @param array<string>|null $allowedLSprofiles Array listing allowed profiles.
2015-08-21 17:51:52 +02:00
* If null, no access control will
* be done for this view.
* @param boolean $showInMenu Show (or not) this view in menu
*
* @return bool True is the view have been registred, false otherwise
2015-08-21 17:51:52 +02:00
**/
public static function registerLSaddonView($LSaddon,$viewId,$label,$viewFunction,$allowedLSprofiles=null,$showInMenu=True) {
2015-08-21 17:51:52 +02:00
if (function_exists($viewFunction)) {
$func = new ReflectionFunction($viewFunction);
if (basename($func->getFileName())=="LSaddons.$LSaddon.php") {
self :: $LSaddonsViews[$LSaddon][$viewId]=array (
'LSaddon' => $LSaddon,
'label' => $label,
'function' => $viewFunction,
'allowedLSprofiles' => $allowedLSprofiles,
'showInMenu' => (bool)$showInMenu
2015-08-21 17:51:52 +02:00
);
return True;
}
else {
2020-09-03 18:31:53 +02:00
LSerror :: addErrorCode(
'LSsession_21',
array(
'func' => $func -> getName(),
'addon' => $LSaddon,
2020-09-03 18:31:53 +02:00
'view' => $viewId,
)
);
2015-08-21 17:51:52 +02:00
}
}
else {
2020-09-03 18:31:53 +02:00
LSerror :: addErrorCode(
'LSsession_23',
array(
'func' => $viewFunction,
'addon' => $LSaddon,
2020-09-03 18:31:53 +02:00
'view' => $viewId,
)
);
2015-08-21 17:51:52 +02:00
}
return False;
}
/**
* Show LSaddon view
*
* @param string $LSaddon The LSaddon
* @param string $viewId The view ID
2015-08-21 17:51:52 +02:00
*
* @return void
2015-08-21 17:51:52 +02:00
**/
public static function showLSaddonView($LSaddon,$viewId) {
if (self :: canAccessLSaddonView($LSaddon,$viewId)) {
call_user_func(self :: $LSaddonsViews[$LSaddon][$viewId]['function']);
}
}
2019-03-11 22:42:20 +01:00
2015-08-21 17:51:52 +02:00
}