[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
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: martinvoegeli@gmx.ch 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 public function __construct() { 57 $this->authtype = 'pam'; 58 $this->config = get_config('auth/pam'); 59 $this->errormessage = ''; 60 } 61 62 /** 63 * Old syntax of class constructor. Deprecated in PHP7. 64 * 65 * @deprecated since Moodle 3.1 66 */ 67 public function auth_plugin_pam() { 68 debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); 69 self::__construct(); 70 } 71 72 /** 73 * Returns true if the username and password work and false if they are 74 * wrong or don't exist. 75 * 76 * @param string $username The username 77 * @param string $password The password 78 * @return bool Authentication success or failure. 79 */ 80 function user_login ($username, $password) { 81 // variable to store possible errors during authentication 82 $errormessage = str_repeat(' ', 2048); 83 84 // just for testing and debugging 85 // error_reporting(E_ALL); 86 87 // call_time_pass_reference of errormessage is deprecated - throws warnings in multiauth 88 //if (pam_auth($username, $password, &$errormessage)) { 89 if (pam_auth($username, $password)) { 90 return true; 91 } 92 else { 93 $this->lasterror = $errormessage; 94 return false; 95 } 96 } 97 98 function prevent_local_passwords() { 99 return true; 100 } 101 102 /** 103 * Returns true if this authentication plugin is 'internal'. 104 * 105 * @return bool 106 */ 107 function is_internal() { 108 return false; 109 } 110 111 /** 112 * Returns true if this authentication plugin can change the user's 113 * password. 114 * 115 * @return bool 116 */ 117 function can_change_password() { 118 return false; 119 } 120 121 /** 122 * Prints a form for configuring this authentication plugin. 123 * 124 * This function is called from admin/auth.php, and outputs a full page with 125 * a form for configuring this plugin. 126 * 127 * @param array $page An object containing all the data for this page. 128 */ 129 function config_form($config, $err, $user_fields) { 130 include "config.html"; 131 } 132 133 /** 134 * Processes and stores configuration data for this authentication plugin. 135 */ 136 function process_config($config) { 137 return true; 138 } 139 140 } 141 142
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |