Merged PAM from stable
authormoodler <moodler>
Fri, 24 Sep 2004 04:46:11 +0000 (04:46 +0000)
committermoodler <moodler>
Fri, 24 Sep 2004 04:46:11 +0000 (04:46 +0000)
auth/pam/config.html [new file with mode: 0644]
auth/pam/lib.php [new file with mode: 0644]

diff --git a/auth/pam/config.html b/auth/pam/config.html
new file mode 100644 (file)
index 0000000..ea85dec
--- /dev/null
@@ -0,0 +1,9 @@
+<tr valign="top"> 
+  <td align="right"><p><?php  print_string("instructions", "auth") ?>:</p></td>
+  <td><textarea name="auth_instructions" cols="30" rows="10" wrap="virtual"><?php  p($config->auth_instructions) ?></textarea> 
+  </td>
+  <td> 
+    <?php  print_string("authinstructions","auth") ?>
+    <?php  helpbutton("text", get_string("helptext")) ?>
+  </td>
+</tr>
\ No newline at end of file
diff --git a/auth/pam/lib.php b/auth/pam/lib.php
new file mode 100644 (file)
index 0000000..24fd39a
--- /dev/null
@@ -0,0 +1,42 @@
+<?PHP  // $Id$
+       //
+       // PAM (Pluggable Authentication Modules) for Moodle 
+       // 
+       // Description:
+       // Authentication by using the PHP4 PAM module:
+       // http://www.math.ohio-state.edu/~ccunning/pam_auth/
+       // 
+       // Version 0.2: 2004/09/01 by Martin Vögeli (stable version)
+       // Version 0.1: 2004/08/30 by Martin Vögeli (first draft)
+       // 
+       // Contact: martinvoegeli@gmx.ch
+       // Website 1: http://elearning.zhwin.ch/
+       // Website 2: http://birdy1976.com/
+       //
+       // License:  GPL License v2
+       // // // // // // // // // // // // // // // // // // //
+
+function auth_user_login ($username, $password) {
+    global $CFG;
+    // returns true if the username and password work
+    // and false if they are wrong or don't exist
+    // variable to store possible errors during authentication
+    $strErrorPAM = " ";
+    // the maximal length of returned messages is 512
+    // let's double the number to give it enough space ;)
+    // (the errror variable is passed by reference)
+    for ($i = 1; $i <= 1024; $i++) {
+        $strErrorPAM += "{$strErrorPAM} ";
+    }
+    // just for testing and debugging
+    // error_reporting(E_ALL);
+    // finally the actual authentication part...
+    if (pam_auth($username, $password, &$strErrorPAM)) {
+        // authentication success
+        return true;
+    } else {
+        // authentication failure
+        return false;
+    }
+}
+?>