mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-15 06:53:04 +01:00
6f52489a59
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
218 lines
7.2 KiB
PHP
218 lines
7.2 KiB
PHP
<?php
|
|
/*******************************************************************************
|
|
* Copyright (C) 2007 Easter-eggs
|
|
* http://ldapsaisie.labs.libre-entreprise.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.
|
|
|
|
******************************************************************************/
|
|
|
|
// Messages d'erreur
|
|
|
|
// Support
|
|
$GLOBALS['LSerror_code']['SAMBA_SUPPORT_01']= array (
|
|
'msg' => _("SAMBA Support : la classe smHash ne peut pas être chargée."),
|
|
'level' => 'c'
|
|
);
|
|
$GLOBALS['LSerror_code']['SAMBA_SUPPORT_02']= array (
|
|
'msg' => _("SAMBA Support : La constante %{const} n'est pas définie."),
|
|
'level' => 'c'
|
|
);
|
|
|
|
$GLOBALS['LSerror_code']['SAMBA_SUPPORT_03']= array (
|
|
'msg' => _("SAMBA Support : Les constantes LS_SAMBA_SID_BASE_USER et LS_SAMBA_SID_BASE_GROUP ne doivent pas avoir la même parité pour l'unicité des sambaSID."),
|
|
'level' => 'c'
|
|
);
|
|
|
|
// Autres erreurs
|
|
$GLOBALS['LSerror_code']['SAMBA_01']= array (
|
|
'msg' => _("SAMBA Support : L'attribut %{dependency} est introuvable. Impossible de générer l'attribut %{attr}."),
|
|
'level' => 'c'
|
|
);
|
|
|
|
/**
|
|
* Verification du support Samba par ldapSaisie
|
|
*
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
*
|
|
* @retval boolean true si Samba est pleinement supporté, false sinon
|
|
*/
|
|
function LSaddon_samba_support() {
|
|
|
|
$retval=true;
|
|
|
|
// Dependance de librairie
|
|
if ( !class_exists('smbHash') ) {
|
|
if ( !LSsession::includeFile(LS_LIB_DIR . 'class.smbHash.php') ) {
|
|
$GLOBALS['LSerror'] -> addErrorCode('SAMBA_SUPPORT_01');
|
|
$retval=false;
|
|
}
|
|
}
|
|
|
|
|
|
$MUST_DEFINE_CONST= array(
|
|
'LS_SAMBA_DOMAIN_SID',
|
|
'LS_SAMBA_SID_BASE_USER',
|
|
'LS_SAMBA_SID_BASE_GROUP',
|
|
'LS_SAMBA_UIDNUMBER_ATTR',
|
|
'LS_SAMBA_GIDNUMBER_ATTR',
|
|
'LS_SAMBA_USERPASSWORD_ATTR'
|
|
);
|
|
|
|
foreach($MUST_DEFINE_CONST as $const) {
|
|
if ( (!defined($const)) || (constant($const) == "")) {
|
|
$GLOBALS['LSerror'] -> addErrorCode('SAMBA_SUPPORT_02',$const);
|
|
$retval=false;
|
|
}
|
|
}
|
|
|
|
// Pour l'intégrité des SID
|
|
if ( (LS_SAMBA_SID_BASE_USER % 2) == (LS_SAMBA_SID_BASE_GROUP % 2) ) {
|
|
$GLOBALS['LSerror'] -> addErrorCode('SAMBA_SUPPORT_03');
|
|
$retval=false;
|
|
}
|
|
|
|
return $retval;
|
|
}
|
|
|
|
/**
|
|
* Generation de sambaSID d'un utilisateur
|
|
*
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
*
|
|
* Number = LS_SAMBA_UIDNUMBER_ATTR * 2 + LS_SAMBA_SID_BASE_USER
|
|
* sambaSID = LS_SAMBA_DOMAIN_SID-Number
|
|
*
|
|
* @param[in] $ldapObject L'objet ldap
|
|
*
|
|
* @retval string SambaSID ou false si il y a un problème durant la génération
|
|
*/
|
|
function generate_sambaUserSID($ldapObject) {
|
|
if ( get_class($ldapObject -> attrs[ LS_SAMBA_UIDNUMBER_ATTR ]) != 'LSattribute' ) {
|
|
$GLOBALS['LSerror'] -> addErrorCode('SAMBA_01',array('dependency' => LS_SAMBA_UIDNUMBER_ATTR, 'attr' => 'sambaSID'));
|
|
return;
|
|
}
|
|
|
|
$uidnumber_attr_val = $ldapObject -> attrs[ LS_SAMBA_UIDNUMBER_ATTR ] -> getValue();
|
|
$uidnumber_attr_val = $uidnumber_attr_val[0];
|
|
$uidNumber = $uidnumber_attr_val * 2 + LS_SAMBA_SID_BASE_USER;
|
|
$sambaSID = LS_SAMBA_DOMAIN_SID . '-' . $uidNumber;
|
|
|
|
return ($sambaSID);
|
|
}
|
|
|
|
/**
|
|
* Generation de sambaSID d'un groupe
|
|
*
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
*
|
|
* Number = LS_SAMBA_GIDNUMBER_ATTR * 2 + LS_SAMBA_SID_BASE_GROUP
|
|
* sambaSID = LS_SAMBA_DOMAIN_SID-Number
|
|
*
|
|
* @param[in] $ldapObject L'objet ldap
|
|
*
|
|
* @retval string SambaSID ou false si il y a un problème durant la génération
|
|
*/
|
|
function generate_sambaGroupSID($ldapObject) {
|
|
if ( get_class($ldapObject -> attrs[ LS_SAMBA_GIDNUMBER_ATTR ]) != 'LSattribute' ) {
|
|
$GLOBALS['LSerror'] -> addErrorCode('SAMBA_01',array('dependency' => LS_SAMBA_GIDNUMBER_ATTR, 'attr' => 'sambaSID'));
|
|
return;
|
|
}
|
|
|
|
$gidnumber_attr_val = $ldapObject -> attrs[ LS_SAMBA_GIDNUMBER_ATTR ] -> getValue();
|
|
$gidnumber_attr_val = $gidnumber_attr_val[0];
|
|
$gidNumber = $gidnumber_attr_val * 2 + LS_SAMBA_SID_BASE_GROUP;
|
|
$sambaSID = LS_SAMBA_DOMAIN_SID . '-' . $gidNumber;
|
|
|
|
return ($sambaSID);
|
|
}
|
|
|
|
/**
|
|
* Generation de sambaPrimaryGroupSID
|
|
*
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
*
|
|
* Number = LS_SAMBA_GIDNUMBER_ATTR * 2 + LS_SAMBA_SID_BASE_GROUP
|
|
* sambaSID = LS_SAMBA_DOMAIN_SID-Number
|
|
*
|
|
* @param[in] $ldapObject L'objet ldap
|
|
*
|
|
* @retval string sambaPrimaryGroupSID ou false si il y a un problème durant la génération
|
|
*/
|
|
function generate_sambaPrimaryGroupSID($ldapObject) {
|
|
if ( get_class($ldapObject -> attrs[ LS_SAMBA_GIDNUMBER_ATTR ]) != 'LSattribute' ) {
|
|
$GLOBALS['LSerror'] -> addErrorCode('SAMBA_02',array('dependency' => LS_SAMBA_GIDNUMBER_ATTR, 'attr' => 'sambaPrimaryGroupSID'));
|
|
return;
|
|
}
|
|
|
|
$gidNumber = $ldapObject -> attrs[ LS_SAMBA_GIDNUMBER_ATTR ] -> getValue();
|
|
$gidNumber = $gidNumber[0] * 2 + LS_SAMBA_SID_BASE_GROUP;
|
|
$sambaPrimaryGroupSID = LS_SAMBA_DOMAIN_SID . '-' . $gidNumber;
|
|
|
|
return ($sambaPrimaryGroupSID);
|
|
}
|
|
|
|
/**
|
|
* Generation de sambaNTPassword
|
|
*
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
*
|
|
* @param[in] $ldapObject L'objet ldap
|
|
*
|
|
* @retval string sambaNTPassword ou false si il y a un problème durant la génération
|
|
*/
|
|
function generate_sambaNTPassword($ldapObject) {
|
|
if ( get_class($ldapObject -> attrs[ LS_SAMBA_USERPASSWORD_ATTR ]) != 'LSattribute' ) {
|
|
$GLOBALS['LSerror'] -> addErrorCode('SAMBA_03',array('dependency' => LS_SAMBA_USERPASSWORD_ATTR, 'attr' => 'sambaNTPassword'));
|
|
return;
|
|
}
|
|
|
|
$password = $ldapObject -> attrs[ LS_SAMBA_USERPASSWORD_ATTR ] -> ldap -> getClearPassword();
|
|
$sambapassword = new smbHash;
|
|
$sambaNTPassword = $sambapassword -> nthash($password);
|
|
|
|
if($sambaNTPassword == '') {
|
|
return;
|
|
}
|
|
return $sambaNTPassword;
|
|
}
|
|
|
|
/**
|
|
* Generation de sambaLMPassword
|
|
*
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
*
|
|
* @param[in] $ldapObject L'objet ldap
|
|
*
|
|
* @retval string sambaLMPassword ou false si il y a un problème durant la génération
|
|
*/
|
|
function generate_sambaLMPassword($ldapObject) {
|
|
if ( get_class($ldapObject -> attrs[ LS_SAMBA_USERPASSWORD_ATTR ]) != 'LSattribute' ) {
|
|
$GLOBALS['LSerror'] -> addErrorCode('SAMBA_04',array('dependency' => LS_SAMBA_USERPASSWORD_ATTR, 'attr' => 'sambaLMPassword'));
|
|
return;
|
|
}
|
|
|
|
$password = $ldapObject -> attrs[ LS_SAMBA_USERPASSWORD_ATTR ] -> ldap -> getClearPassword();
|
|
$sambapassword = new smbHash;
|
|
$sambaLMPassword = $sambapassword -> lmhash($password);
|
|
|
|
if($sambaLMPassword == '') {
|
|
return;
|
|
}
|
|
return $sambaLMPassword;
|
|
}
|
|
|
|
?>
|