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 * Base of a authentication provider for LSauth
26 * @author Benjamin Renard <brenard@easter-eggs.com>
30 var $authData = array();
32 function LSauthMethod() {
34 LSsession :: includeFile(LS_CONF_DIR."LSauth/config.".get_class($this).".php");
35 LSdebug(LS_CONF_DIR."LSauth/config.".get_class($this).".php");
42 * Return authentication data or false
44 * @retval Array|false Array of authentication data or False
46 public function getAuthData() {
47 // Do nothing in the standard LSauthMethod class
48 // This method have to define $this -> authData['username']
53 * Check authentication
55 * @retval LSldapObject|false The LSldapObject of the user authificated or false
57 public function authenticate() {
58 if (LSsession :: loadLSobject(LSsession :: $ldapServer['authObjectType'])) {
59 $authobject = new LSsession :: $ldapServer['authObjectType']();
60 $result = $authobject -> searchObject(
61 $this -> authData['username'],
62 LSsession :: getTopDn(),
63 LSsession :: $ldapServer['authObjectFilter']
65 $nbresult=count($result);
69 LSdebug('identifiant incorrect');
70 LSerror :: addErrorCode('LSauth_01');
72 else if ($nbresult>1) {
73 // duplication of identity
74 LSerror :: addErrorCode('LSauth_02');
81 LSerror :: addErrorCode('LSauth_03');
89 * @retval boolean True on success or False
91 public function logout() {
92 // Do nothing in the standard LSauthMethod class