2007-11-15 19:07:24 +01:00
|
|
|
|
<?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.
|
|
|
|
|
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Type d'attribut Ldap password
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
class LSattr_ldap_password extends LSattr_ldap {
|
|
|
|
|
|
2008-02-12 18:59:44 +01:00
|
|
|
|
var $clearPassword = NULL;
|
2007-11-15 19:07:24 +01:00
|
|
|
|
|
2008-02-12 18:59:44 +01:00
|
|
|
|
/**
|
|
|
|
|
* Retourne la valeur d'affichage de l'attribut apr<EFBFBD>s traitement li<EFBFBD> <EFBFBD> son type ldap
|
|
|
|
|
*
|
|
|
|
|
* @param[in] $data mixed La valeur de l'attribut
|
|
|
|
|
*
|
|
|
|
|
* @retval mixed La valeur d'affichage de l'attribut
|
|
|
|
|
*/
|
2007-11-15 19:07:24 +01:00
|
|
|
|
function getDisplayValue($data) {
|
|
|
|
|
return '********';
|
|
|
|
|
}
|
|
|
|
|
|
2008-02-12 18:59:44 +01:00
|
|
|
|
/**
|
|
|
|
|
* Retourne la valeur de l'attribut apr<EFBFBD>s traitement li<EFBFBD> <EFBFBD> son type ldap
|
|
|
|
|
*
|
|
|
|
|
* @param[in] $data mixed La valeur de l'attribut
|
|
|
|
|
*
|
|
|
|
|
* @retval mixed La valeur trait<EFBFBD>e de l'attribut
|
|
|
|
|
*/
|
2007-11-15 19:07:24 +01:00
|
|
|
|
function getUpdateData($data) {
|
2008-02-12 18:59:44 +01:00
|
|
|
|
$this -> clearPassword = $data[0];
|
2007-11-15 19:07:24 +01:00
|
|
|
|
return '{CRYPT}'.crypt($data[0],'$1$'.$this -> getSalt().'$');
|
|
|
|
|
}
|
|
|
|
|
|
2008-02-12 18:59:44 +01:00
|
|
|
|
/**
|
|
|
|
|
* Retourne une salt (chaine de caract<EFBFBD>re al<EFBFBD>atoire) de la longueur pass<EFBFBD>e en param<EFBFBD>tre
|
|
|
|
|
*
|
|
|
|
|
* @param[in] integer La longueur de la salt (par defaut : 8)
|
|
|
|
|
*
|
|
|
|
|
* @retval string La salt
|
|
|
|
|
*/
|
2007-11-15 19:07:24 +01:00
|
|
|
|
function getSalt($length=8) {
|
|
|
|
|
$pattern = "1234567890abcdefghijklmnopqrstuvwxyz";
|
|
|
|
|
$key = $pattern{rand(0,35)};
|
|
|
|
|
for($i=1;$i<$length;$i++)
|
|
|
|
|
{
|
|
|
|
|
$key .= $pattern{rand(0,35)};
|
|
|
|
|
}
|
|
|
|
|
return $key;
|
|
|
|
|
}
|
|
|
|
|
|
2008-02-12 18:59:44 +01:00
|
|
|
|
/**
|
|
|
|
|
* Retourne le mot de passe en texte clair
|
|
|
|
|
*
|
|
|
|
|
* @retval string Le mot de passe en texte clair
|
|
|
|
|
*/
|
|
|
|
|
function getClearPassword() {
|
|
|
|
|
return $this -> clearPassword;
|
|
|
|
|
}
|
2007-11-15 19:07:24 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|