Another wretched adslashes problem. Roll on placeholder. Thanks to Howard Miller...
[moodle.git] / auth / pam / auth.php
CommitLineData
b9ddb2d5 1<?php
2
3/**
4 * @author Martin Dougiamas
5 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
6 * @package moodle multiauth
7 *
8 * Authentication Plugin: PAM Authentication
9 *
10 * PAM (Pluggable Authentication Modules) for Moodle
11 *
12 * Description:
13 * Authentication by using the PHP4 PAM module:
14 * http://www.math.ohio-state.edu/~ccunning/pam_auth/
15 *
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)
19 *
20 * Contact: martinvoegeli@gmx.ch
21 * Website 1: http://elearning.zhwin.ch/
22 * Website 2: http://birdy1976.com/
23 *
24 * License: GPL License v2
25 *
26 * 2006-08-31 File created.
27 */
28
29// This page cannot be called directly
30if (!isset($CFG)) exit;
31
32/**
33 * PAM authentication plugin.
34 */
35class auth_plugin_pam {
36
37 /**
38 * The configuration details for the plugin.
39 */
40 var $config;
41
42 /**
43 * Store error messages from pam authentication attempts.
44 */
45 var $lasterror;
46
47 /**
48 * Constructor.
49 */
50 function auth_plugin_pam() {
51 $this->config = get_config('auth/pam');
52 $this->errormessage = '';
53 }
54
55 /**
56 * Returns true if the username and password work and false if they are
57 * wrong or don't exist.
58 *
59 * @param string $username The username
60 * @param string $password The password
61 * @returns bool Authentication success or failure.
62 */
63 function user_login ($username, $password) {
64 // variable to store possible errors during authentication
65 $errormessage = str_repeat(' ', 2048);
66
67 // just for testing and debugging
68 // error_reporting(E_ALL);
b91c36bf 69
70 // call_time_pass_reference of errormessage is deprecated - throws warnings in multiauth
71 //if (pam_auth($username, $password, &$errormessage)) {
72 if (pam_auth($username, $password)) {
b9ddb2d5 73 return true;
74 }
75 else {
76 $this->lasterror = $errormessage;
77 return false;
78 }
79 }
80
81 /**
82 * Returns true if this authentication plugin is 'internal'.
83 *
84 * @returns bool
85 */
86 function is_internal() {
87 return false;
88 }
89
90 /**
91 * Returns true if this authentication plugin can change the user's
92 * password.
93 *
94 * @returns bool
95 */
96 function can_change_password() {
97 return false;
98 }
99
100 /**
101 * Prints a form for configuring this authentication plugin.
102 *
103 * This function is called from admin/auth.php, and outputs a full page with
104 * a form for configuring this plugin.
105 *
106 * @param array $page An object containing all the data for this page.
107 */
108 function config_form($config, $err) {
109 include "config.html";
110 }
111
112 /**
113 * Processes and stores configuration data for this authentication plugin.
114 */
115 function process_config($config) {
116 return true;
117 }
118
119}
120
121?>