2 /*******************************************************************************
3 * Copyright (C) 2007 Easter-eggs
4 * http://ldapsaisie.labs.libre-entreprise.org
6 * Author: See AUTHORS file in top-level directory.
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version 2
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 ******************************************************************************/
24 * Basic authentication provider for LSauth
26 * @author Benjamin Renard <brenard@easter-eggs.com>
28 class LSauthMethod_basic extends LSauthMethod {
33 * Return authentication data or false
35 * @retval Array|false Array of authentication data or False
37 public function getAuthData() {
38 if (isset($_POST['LSauth_user']) && !empty($_POST['LSauth_user'])) {
39 $this -> authData = array(
40 'username' => $_POST['LSauth_user'],
41 'password' => (isset($_POST['LSauth_pwd'])?$_POST['LSauth_pwd']:'')
43 return $this -> authData;
49 * Check authentication
51 * @retval LSldapObject|false The LSldapObject of the user authificated or false
53 public function authenticate() {
54 $authobject = parent :: authenticate();
56 if ( $this -> checkUserPwd($authobject,$this -> authData['password']) ) {
57 // Authentication succeeded
61 LSerror :: addErrorCode('LSauth_01');
62 LSdebug('mdp incorrect');
69 * Test un couple LSobject/pwd
71 * Test un bind sur le serveur avec le dn de l'objet et le mot de passe fourni.
73 * @param[in] LSobject L'object "user" pour l'authentification
74 * @param[in] string Le mot de passe à tester
76 * @retval boolean True si l'authentification a reussi, false sinon.
78 public static function checkUserPwd($object,$pwd) {
79 return LSldap :: checkBind($object -> getValue('dn'),$pwd);