function auth_user_login ($username, $password) { // Returns true if the username and password work // and false if they are wrong or don't exist. require_once 'Auth/RADIUS.php'; global $CFG; // Added by Clive on 7th May for test purposes // printf("Username: $username
"); // printf("Password: $password
"); // printf("auth_radiushost: $CFG->auth_radiushost
"); // printf("auth_radiusnasport: $CFG->auth_radiusnasport
"); // printf("auth_radiussecret: $CFG->auth_radiussecret
"); $rauth = new Auth_RADIUS_PAP($username, $password); $rauth->addServer($CFG->auth_radiushost, $CFG->auth_radiusnasport, $CFG->auth_radiussecret); if (!$rauth->start()) { printf("Radius start: %s
\n", $rauth->getError()); exit; } $result = $rauth->send(); if (PEAR::isError($result)) { printf("Radius send failed: %s
\n", $result->getMessage()); exit; } else if ($result === true) { // printf("Radius Auth succeeded
\n"); return true; } else { // printf("Radius Auth rejected
\n"); return false; } // get attributes, even if auth failed if (!$rauth->getAttributes()) { printf("Radius getAttributes: %s
\n", $rauth->getError()); } else { $rauth->dumpAttributes(); } $rauth->close(); } ?>