[ Index ]
 

Code source de Horde 3.1.3

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

title

Body

[fermer]

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

   1  <?php
   2  /**
   3   * The Auth_smb class provides an SMB implementation of the Horde
   4   * authentication system.
   5   *
   6   * This module requires the smbauth extension for PHP:
   7   *   http://www.tekrat.com/smbauth/
   8   *
   9   * At the time of this writing, the extension, and thus this module, only
  10   * supported authentication against a domain, and pdc and bdc must be non-null
  11   * and not equal to each other. In other words, to use this module you must
  12   * have a domain with at least one PDC and one BDC.
  13   *
  14   * Required parameters:<pre>
  15   *   'hostspec'  IP, DNS Name, or NetBios Name of the SMB server to
  16   *               authenticate with.
  17   *   'domain'    The domain name to authenticate with.</pre>
  18   *
  19   * Optional parameters:<pre>
  20   *   'group'     Group name that the user must be a member of. Will be
  21   *               ignored if the value passed is a zero length string.</pre>
  22   *
  23   *
  24   * $Horde: framework/Auth/Auth/smb.php,v 1.20.10.8 2006/01/01 21:28:07 jan Exp $
  25   *
  26   * Copyright 1999-2006 Jon Parise <jon@horde.org>
  27   * Copyright 2002-2006 Marcus I. Ryan <marcus@riboflavin.net>
  28   *
  29   * See the enclosed file COPYING for license information (LGPL). If you
  30   * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
  31   *
  32   * @author  Jon Parise <jon@horde.org>
  33   * @author  Marcus I. Ryan <marcus@riboflavin.net>
  34   * @since   Horde 3.0
  35   * @package Horde_Auth
  36   */
  37  class Auth_smb extends Auth {
  38  
  39      /**
  40       * An array of capabilities, so that the driver can report which
  41       * operations it supports and which it doesn't.
  42       *
  43       * @var array
  44       */
  45      var $capabilities = array('add'           => false,
  46                                'update'        => false,
  47                                'resetpassword' => false,
  48                                'remove'        => false,
  49                                'list'          => false,
  50                                'transparent'   => false);
  51  
  52      /**
  53       * Constructs a new SMB authentication object.
  54       *
  55       * @param array $params  A hash containing connection parameters.
  56       */
  57      function Auth_smb($params = array())
  58      {
  59          if (!Util::extensionExists('smbauth')) {
  60              Horde::fatal(_("Auth_smbauth: Required smbauth extension not found."), __FILE__, __LINE__);
  61          }
  62  
  63          /* Ensure we've been provided with all of the necessary parameters. */
  64          Horde::assertDriverConfig($params, 'auth',
  65              array('hostspec', 'domain'),
  66              'authentication Samba');
  67  
  68          $this->_params = $params;
  69      }
  70  
  71      /**
  72       * Find out if the given set of login credentials are valid.
  73       *
  74       * @access private
  75       *
  76       * @param string $userId      The userId to check.
  77       * @param array $credentials  An array of login credentials.
  78       *
  79       * @return boolean  True on success or a PEAR_Error object on failure.
  80       */
  81      function _authenticate($userId, $credentials)
  82      {
  83          if (empty($credentials['password'])) {
  84              Horde::fatal(_("No password provided for SMB authentication."), __FILE__, __LINE__);
  85          }
  86  
  87          /* Authenticate. */
  88          $rval = validate($this->_params['hostspec'],
  89                           $this->_params['domain'],
  90                           empty($this->_params['group']) ? '' : $this->_params['group'],
  91                           $userId,
  92                           $credentials['password']);
  93  
  94          if ($rval === 0) {
  95              return true;
  96          } else {
  97              if ($rval === 1) {
  98                  $this->_setAuthError(AUTH_REASON_MESSAGE, _("Failed to connect to SMB server."));
  99              } else {
 100                  $this->_setAuthError(AUTH_REASON_MESSAGE, err2str());
 101              }
 102              return false;
 103          }
 104      }
 105  
 106  }


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