mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-12-19 06:53:53 +01:00
3e823a2b22
-> 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
102 lines
3.1 KiB
PHP
102 lines
3.1 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.
|
|
|
|
******************************************************************************/
|
|
|
|
/**
|
|
* Gestion de l'authentification d'un utilisateur
|
|
*
|
|
* Cette classe gere l'authentification des utilisateurs à l'interface
|
|
*
|
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
*/
|
|
class LSauth {
|
|
|
|
/**
|
|
* Check user login
|
|
*
|
|
* @param[in] $username The username
|
|
* @param[in] $password The password
|
|
*
|
|
* @retval LSldapObject|false The LSldapObject of the user authificated or false
|
|
*/
|
|
public static function authenticate($username,$password) {
|
|
if (LSsession :: loadLSobject(LSsession :: $ldapServer['authObjectType'])) {
|
|
$authobject = new LSsession :: $ldapServer['authObjectType']();
|
|
$result = $authobject -> searchObject(
|
|
$username,
|
|
LSsession :: getTopDn(),
|
|
LSsession :: $ldapServer['authObjectFilter']
|
|
);
|
|
$nbresult=count($result);
|
|
|
|
if ($nbresult==0) {
|
|
// identifiant incorrect
|
|
LSdebug('identifiant incorrect');
|
|
LSerror :: addErrorCode('LSauth_01');
|
|
}
|
|
else if ($nbresult>1) {
|
|
// duplication d'authentité
|
|
LSerror :: addErrorCode('LSauth_02');
|
|
}
|
|
elseif ( self :: checkUserPwd($result[0],$password) ) {
|
|
// Authentication succeeded
|
|
return $result[0];
|
|
}
|
|
else {
|
|
LSerror :: addErrorCode('LSauth_01');
|
|
LSdebug('mdp incorrect');
|
|
}
|
|
}
|
|
else {
|
|
LSerror :: addErrorCode('LSauth_03');
|
|
}
|
|
return;
|
|
}
|
|
|
|
/**
|
|
* Test un couple LSobject/pwd
|
|
*
|
|
* Test un bind sur le serveur avec le dn de l'objet et le mot de passe fourni.
|
|
*
|
|
* @param[in] LSobject L'object "user" pour l'authentification
|
|
* @param[in] string Le mot de passe à tester
|
|
*
|
|
* @retval boolean True si l'authentification à réussi, false sinon.
|
|
*/
|
|
public static function checkUserPwd($object,$pwd) {
|
|
return LSldap :: checkBind($object -> getValue('dn'),$pwd);
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
* Error Codes
|
|
*/
|
|
LSerror :: defineError('LSauth_01',
|
|
_("LSauth : Login or password incorrect.")
|
|
);
|
|
LSerror :: defineError('LSauth_02',
|
|
_("LSauth : Impossible to identify you : Duplication of identities.")
|
|
);
|
|
LSerror :: defineError('LSauth_03',
|
|
_("LSsession : Could not load type of identifiable objects.")
|
|
);
|
|
?>
|