From dce48fc85a6eb1279facbcff4cb2d0ce048b3249 Mon Sep 17 00:00:00 2001 From: moodler Date: Fri, 15 Nov 2002 08:25:24 +0000 Subject: [PATCH] First version of code to authenticate against external database. This NOT TESTED yet, and has parameters hardcoded ... it will of course be using Petri's config interface later when that's ready. --- auth/db/lib.php | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 auth/db/lib.php diff --git a/auth/db/lib.php b/auth/db/lib.php new file mode 100644 index 0000000000..5cee2d66fe --- /dev/null +++ b/auth/db/lib.php @@ -0,0 +1,43 @@ +authdbhost = "localhost"; +$CFG->authdbtype = "mysql"; // (postgresql, etc) +$CFG->authdbname = "authtest"; +$CFG->authdbtable = "users"; +$CFG->authdbuser = "user"; +$CFG->authdbpass = "pass"; +$CFG->authdbfielduser = "user"; +$CFG->authdbfieldpass = "pass"; + +function auth_user_login ($username, $password) { +// Returns true if the username and password work +// and false if they are wrong or don't exist. + + global $CFG; + + ADOLoadCode($CFG->authdbtype); + $authdb = &ADONewConnection(); + $authdb->PConnect($CFG->authdbhost,$CFG->authdbuser,$CFG->authdbpass,$CFG->authdbname); + + + $rs = $authdb->Execute("SELECT * FROM $CFG->authdbtable + WHERE $CFG->authdbfielduser = '$username' + AND $CFG->authdbfieldpass = '$password' "); + if (!$rs) { + notify("Could not connect to the specified authentication database..."); + return false; + } + + if ( $rs->RecordCount() ) { + return true; + } else { + return false; + } +} + + +?> -- 2.39.5