[ Index ]
 

Code source de Horde 3.1.3

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/Horde/Auth/ -> pam.php (source)

   1  <?php
   2  /**
   3   * The Auth_pam:: class provides a PAM-based implementation of the Horde
   4   * authentication system.
   5   *
   6   * PAM (Pluggable Authentication Modules) is a flexible mechanism for
   7   * authenticating users.  It has become the standard authentication system for
   8   * Linux, Solaris and FreeBSD.
   9   *
  10   * This implementation requires Chad Cunningham's pam_auth extension:
  11   *
  12   *      http://www.math.ohio-state.edu/~ccunning/pam_auth/
  13   *
  14   * Optional parameters:<pre>
  15   *   'service'  The name of the PAM service to use when authenticating.
  16   *              DEFAULT: php</pre>
  17   *
  18   *
  19   * $Horde: framework/Auth/Auth/pam.php,v 1.3.10.11 2006/01/01 21:28:07 jan Exp $
  20   *
  21   * Copyright 2004-2006 Jon Parise <jon@horde.org>
  22   *
  23   * See the enclosed file COPYING for license information (LGPL). If you
  24   * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
  25   *
  26   * @author  Jan Parise <jon@horde.org>
  27   * @since   Horde 3.0
  28   * @package Horde_Auth
  29   */
  30  class Auth_pam extends Auth {
  31  
  32      /**
  33       * An array of capabilities, so that the driver can report which
  34       * operations it supports and which it doesn't.
  35       *
  36       * @var array
  37       */
  38      var $capabilities = array('add'           => false,
  39                                'update'        => false,
  40                                'resetpassword' => false,
  41                                'remove'        => false,
  42                                'list'          => false,
  43                                'transparent'   => false);
  44  
  45      /**
  46       * Constructs a new PAM authentication object.
  47       *
  48       * @param array $params  A hash containing connection parameters.
  49       */
  50      function Auth_pam($params = array())
  51      {
  52          $this->_params = $params;
  53          if (!empty($params['service'])) {
  54              ini_set('pam_auth.servicename', $params['service']);
  55          }
  56  
  57          if (!extension_loaded('pam_auth')) {
  58              dl('pam_auth.so');
  59          }
  60      }
  61  
  62      /**
  63       * Find out if a set of login credentials are valid.
  64       *
  65       * @access private
  66       *
  67       * @param string $userId      The userId to check.
  68       * @param array $credentials  An array of login credentials.
  69       *
  70       * @return boolean  Whether or not the credentials are valid.
  71       */
  72      function _authenticate($userId, $credentials)
  73      {
  74          if (empty($credentials['password'])) {
  75              Horde::fatal(_("No password provided for Login authentication."), __FILE__, __LINE__);
  76          }
  77  
  78          if (!extension_loaded('pam_auth')) {
  79              Horde::fatal(_("PAM authentication is not available."), __FILE__, __LINE__);
  80          }
  81  
  82          if (!pam_auth($userId, $credentials['password'], &$error)) {
  83              $this->_setAuthError(AUTH_REASON_MESSAGE, $error);
  84              return false;
  85          }
  86  
  87          return true;
  88      }
  89  }


Généré le : Sun Feb 25 18:01:28 2007 par Balluche grâce à PHPXref 0.7