4 * @author Martin Dougiamas
5 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
6 * @package moodle multiauth
8 * Authentication Plugin: PAM Authentication
10 * PAM (Pluggable Authentication Modules) for Moodle
13 * Authentication by using the PHP4 PAM module:
14 * http://www.math.ohio-state.edu/~ccunning/pam_auth/
16 * Version 0.3 2006/09/07 by Jonathan Harker (plugin class)
17 * Version 0.2: 2004/09/01 by Martin V�geli (stable version)
18 * Version 0.1: 2004/08/30 by Martin V�geli (first draft)
20 * Contact: martinvoegeli@gmx.ch
21 * Website 1: http://elearning.zhwin.ch/
22 * Website 2: http://birdy1976.com/
24 * License: GPL License v2
26 * 2006-08-31 File created.
29 // This page cannot be called directly
30 if (!isset($CFG)) exit;
33 * PAM authentication plugin.
35 class auth_plugin_pam {
38 * The configuration details for the plugin.
43 * Store error messages from pam authentication attempts.
50 function auth_plugin_pam() {
51 $this->config = get_config('auth/pam');
52 $this->errormessage = '';
56 * Returns true if the username and password work and false if they are
57 * wrong or don't exist.
59 * @param string $username The username
60 * @param string $password The password
61 * @returns bool Authentication success or failure.
63 function user_login ($username, $password) {
64 // variable to store possible errors during authentication
65 $errormessage = str_repeat(' ', 2048);
67 // just for testing and debugging
68 // error_reporting(E_ALL);
69 if (pam_auth($username, $password, &$errormessage)) {
73 $this->lasterror = $errormessage;
79 * Returns true if this authentication plugin is 'internal'.
83 function is_internal() {
88 * Returns true if this authentication plugin can change the user's
93 function can_change_password() {
98 * Prints a form for configuring this authentication plugin.
100 * This function is called from admin/auth.php, and outputs a full page with
101 * a form for configuring this plugin.
103 * @param array $page An object containing all the data for this page.
105 function config_form($config, $err) {
106 include "config.html";
110 * Processes and stores configuration data for this authentication plugin.
112 function process_config($config) {