[ Index ]

PHP Cross Reference of moodle-2.8

title

Body

[close]

/auth/pam/ -> auth.php (source)

   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * Authentication Plugin: PAM Authentication
  19   *
  20   * PAM (Pluggable Authentication Modules) for Moodle
  21   *
  22   * Description:
  23   * Authentication by using the PHP4 PAM module:
  24   * http://www.math.ohio-state.edu/~ccunning/pam_auth/
  25   *
  26   * Version 0.3  2006/09/07 by Jonathan Harker (plugin class)
  27   * Version 0.2: 2004/09/01 by Martin V�geli (stable version)
  28   * Version 0.1: 2004/08/30 by Martin V�geli (first draft)
  29   *
  30   * Contact: [email protected]
  31   * Website 1: http://elearning.zhwin.ch/
  32   * Website 2: http://birdy1976.com/
  33   *
  34   * @package auth_pam
  35   * @author Martin Dougiamas
  36   * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
  37   */
  38  
  39  defined('MOODLE_INTERNAL') || die();
  40  
  41  require_once($CFG->libdir.'/authlib.php');
  42  
  43  /**
  44   * PAM authentication plugin.
  45   */
  46  class auth_plugin_pam extends auth_plugin_base {
  47  
  48      /**
  49       * Store error messages from pam authentication attempts.
  50       */
  51      var $lasterror;
  52  
  53      /**
  54       * Constructor.
  55       */
  56      function auth_plugin_pam() {
  57          $this->authtype = 'pam';
  58          $this->config = get_config('auth/pam');
  59          $this->errormessage = '';
  60      }
  61  
  62      /**
  63       * Returns true if the username and password work and false if they are
  64       * wrong or don't exist.
  65       *
  66       * @param string $username The username
  67       * @param string $password The password
  68       * @return bool Authentication success or failure.
  69       */
  70      function user_login ($username, $password) {
  71          // variable to store possible errors during authentication
  72          $errormessage = str_repeat(' ', 2048);
  73  
  74          // just for testing and debugging
  75          // error_reporting(E_ALL);
  76  
  77          // call_time_pass_reference of errormessage is deprecated - throws warnings in multiauth
  78          //if (pam_auth($username, $password, &$errormessage)) {
  79          if (pam_auth($username, $password)) {
  80              return true;
  81          }
  82          else {
  83              $this->lasterror = $errormessage;
  84              return false;
  85          }
  86      }
  87  
  88      function prevent_local_passwords() {
  89          return true;
  90      }
  91  
  92      /**
  93       * Returns true if this authentication plugin is 'internal'.
  94       *
  95       * @return bool
  96       */
  97      function is_internal() {
  98          return false;
  99      }
 100  
 101      /**
 102       * Returns true if this authentication plugin can change the user's
 103       * password.
 104       *
 105       * @return bool
 106       */
 107      function can_change_password() {
 108          return false;
 109      }
 110  
 111      /**
 112       * Prints a form for configuring this authentication plugin.
 113       *
 114       * This function is called from admin/auth.php, and outputs a full page with
 115       * a form for configuring this plugin.
 116       *
 117       * @param array $page An object containing all the data for this page.
 118       */
 119      function config_form($config, $err, $user_fields) {
 120          include  "config.html";
 121      }
 122  
 123      /**
 124       * Processes and stores configuration data for this authentication plugin.
 125       */
 126      function process_config($config) {
 127          return true;
 128      }
 129  
 130  }
 131  
 132  


Generated: Fri Nov 28 20:29:05 2014 Cross-referenced by PHPXref 0.7.1