moodle/auth/db/lib.php
moodler 35a48c9ae4 A significant new system for authentication configuration that
exposes the wide array of authentication possibilities.

Authentication now has it's own page separate from other variables.

Most of this work was done by Petri Asikainen <paca@sci.fi>, who started
these changes off.

I've done some cleanups and additions which is why I'm checking it in.

It's all working pretty well at the moment but could use some testing.

Thanks, Petri!  :-)
2002-11-19 08:51:33 +00:00

36 lines
978 B
PHP

<?PHP // $Id$
// Authentication by looking up an external database table
// This code is completely untested so far - IT NEEDS TESTERS!
// Looks like it should work though ...
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->auth_dbtype);
$authdb = &ADONewConnection();
$authdb->PConnect($CFG->auth_dbhost,$CFG->auth_dbuser,$CFG->auth_dbpass,$CFG->auth_dbname);
$rs = $authdb->Execute("SELECT * FROM $CFG->auth_dbtable
WHERE $CFG->auth_dbfielduser = '$username'
AND $CFG->auth_dbfieldpass = '$password' ");
if (!$rs) {
notify("Could not connect to the specified authentication database...");
return false;
}
if ( $rs->RecordCount() ) {
return true;
} else {
return false;
}
}
?>