| [ Index ] |
|
Code source de Horde 3.1.3 |
1 <?php 2 /** 3 * The Auth_mcal class provides an MCAL implementation of the Horde 4 * authentication system. 5 * 6 * MCAL Home Page: http://mcal.chek.com/ 7 * 8 * Required parameters:<pre> 9 * 'calendar' The MCAL calendar name.</pre> 10 * 11 * 12 * $Horde: framework/Auth/Auth/mcal.php,v 1.27.10.9 2006/01/01 21:28:07 jan Exp $ 13 * 14 * Copyright 1999-2006 Chuck Hagenbuch <chuck@horde.org> 15 * 16 * See the enclosed file COPYING for license information (LGPL). If you 17 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. 18 * 19 * @author Chuck Hagenbuch <chuck@horde.org> 20 * @since Horde 1.3 21 * @package Horde_Auth 22 */ 23 class Auth_mcal extends Auth { 24 25 /** 26 * An array of capabilities, so that the driver can report which 27 * operations it supports and which it doesn't. 28 * 29 * @var array 30 */ 31 var $capabilities = array('add' => false, 32 'update' => false, 33 'resetpassword' => false, 34 'remove' => false, 35 'list' => true, 36 'transparent' => false); 37 38 /** 39 * Constructs a new MCAL authentication object. 40 * 41 * @param array $params A hash containing connection parameters. 42 */ 43 function Auth_mcal($params = array()) 44 { 45 if (!Util::extensionExists('mcal')) { 46 Horde::fatal(_("Auth_mcal: Required MCAL extension not found."), __FILE__, __LINE__); 47 } 48 49 if (empty($params['calendar'])) { 50 Horde::fatal(_("No calendar name provided for MCAL authentication."), __FILE__, __LINE__); 51 } 52 53 $this->_params = $params; 54 } 55 56 /** 57 * Find out if a set of login credentials are valid. 58 * 59 * @access private 60 * 61 * @param string $userId The userId to check. 62 * @param array $credentials An array of login credentials. For MCAL, 63 * this must contain a password entry. 64 * 65 * @return boolean Whether or not the credentials are valid. 66 */ 67 function _authenticate($userId, $credentials) 68 { 69 $mcal = @mcal_open($this->_params['calendar'], $userId, $credentials['password']); 70 71 if ($mcal) { 72 @mcal_close($mcal); 73 return true; 74 } else { 75 @mcal_close($mcal); 76 $this->_setAuthError(AUTH_REASON_BADLOGIN); 77 return false; 78 } 79 } 80 81 /** 82 * List all users in the system. 83 * 84 * @return mixed The array of userIds, or a PEAR_Error object on failure. 85 */ 86 function listUsers() 87 { 88 $lines = @file('/etc/mpasswd'); 89 if (!$lines || !is_array($lines)) { 90 return PEAR::raiseError('Unable to list users.'); 91 } 92 93 $users = array(); 94 foreach ($lines as $line) { 95 $users[] = substr($line, 0, strpos($line, ':')); 96 } 97 98 return $users; 99 } 100 101 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sun Feb 25 18:01:28 2007 | par Balluche grâce à PHPXref 0.7 |