Overview

Packages

  • Auth

Classes

  • Horde_Auth
  • Horde_Auth_Auto
  • Horde_Auth_Base
  • Horde_Auth_Composite
  • Horde_Auth_Customsql
  • Horde_Auth_Cyrsql
  • Horde_Auth_Exception
  • Horde_Auth_Ftp
  • Horde_Auth_Http
  • Horde_Auth_Http_Remote
  • Horde_Auth_Imap
  • Horde_Auth_Ipbasic
  • Horde_Auth_Kolab
  • Horde_Auth_Ldap
  • Horde_Auth_Login
  • Horde_Auth_Msad
  • Horde_Auth_Pam
  • Horde_Auth_Passwd
  • Horde_Auth_Peclsasl
  • Horde_Auth_Radius
  • Horde_Auth_Shibboleth
  • Horde_Auth_Smb
  • Horde_Auth_Smbclient
  • Horde_Auth_Sql
  • Horde_Auth_Translation
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * The Horde_Auth_Smb class provides a SMB implementation of the Horde
 4:  * authentication system.
 5:  *
 6:  * This module requires the smbauth extension for PHP:
 7:  *   http://tekrat.com/wp/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:  * Copyright 1999-2012 Horde LLC (http://www.horde.org/)
15:  *
16:  * See the enclosed file COPYING for license information (LGPL). If you did
17:  * not receive this file, http://www.horde.org/licenses/lgpl21
18:  *
19:  * @author   Jon Parise <jon@horde.org>
20:  * @author   Marcus I. Ryan <marcus@riboflavin.net>
21:  * @category Horde
22:  * @license http://www.horde.org/licenses/lgpl21 LGPL-2.1
23:  * @package  Auth
24:  */
25: class Horde_Auth_Smb extends Horde_Auth_Base
26: {
27:     /**
28:      * Constructor.
29:      *
30:      * @param array $params  Parameters:
31:      * <pre>
32:      * 'domain' - (string) [REQUIRED] The domain name to authenticate with.
33:      * 'group' - Group name that the user must be a member of.
34:      *           DEFAULT: none
35:      * 'hostspec' - (string) [REQUIRED] IP, DNS Name, or NetBios name of the
36:      *              SMB server to authenticate with.
37:      * </pre>
38:      *
39:      * @throws Horde_Auth_Exception
40:      * @throws InvalidArgumentException
41:      */
42:     public function __construct(array $params = array())
43:     {
44:         if (!Horde_Util::extensionExists('smbauth')) {
45:             throw new Horde_Auth_Exception(__CLASS__ . ': Required smbauth extension not found.');
46:         }
47: 
48:         foreach (array('domain', 'hostspec') as $val) {
49:             throw new InvalidArgumentException('Missing ' . $val . ' parameter.');
50:         }
51: 
52:         $params = array_merge(array(
53:             'group' => null
54:         ), $params);
55: 
56:         parent::__construct($params);
57:     }
58: 
59:     /**
60:      * Find out if the given set of login credentials are valid.
61:      *
62:      * @param string $userId      The userId to check.
63:      * @param array $credentials  An array of login credentials.
64:      *
65:      * @throws Horde_Auth_Exception
66:      */
67:     public function _authenticate($userId, $credentials)
68:     {
69:         if (empty($credentials['password'])) {
70:             throw new Horde_Auth_Exception('', Horde_Auth::REASON_BADLOGIN);
71:         }
72: 
73:         /* Authenticate. */
74:         $rval = validate($this->_params['hostspec'],
75:                          $this->_params['domain'],
76:                          empty($this->_params['group']) ? '' : $this->_params['group'],
77:                          $userId,
78:                          $credentials['password']);
79: 
80:         if ($rval === 1) {
81:             throw new Horde_Auth_Exception('Failed to connect to SMB server.');
82:         } elseif ($rval !== 0) {
83:             throw new Horde_Auth_Exception(err2str());
84:         }
85:     }
86: 
87: }
88: 
API documentation generated by ApiGen