Using PHP and cURL you can easily authenticate users using NetClassroom.
You will have to create a login page with a form that contains username and password fields, and then post it to the file below:
We have NetClassroom running in HTTPS on IIS, if you dont (you should) remove the following line:
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
The script takes the username and password and then using cURL sends it to the NetClassroom login.aspx page where it scrapes the authentication information from the cookie. Because the way NC was designed you can not scrape any information off of the NC pages (they use javascript for everything) but we can authenticate users securely.
A successfull login will say: Sucessfull Login!
A failed login will say: Login Failed
Due to posting limitations here I had to modify the $viewstate variable - it should be on ONE line.
<?$username = urlencode($HTTP_POST_VARS['username']);$password = urlencode($HTTP_POST_VARS['password']);
session_start();$useragent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1";$file = tempnam('/tmp', 'netclass');$viewstate = urlencode("/wEPDwUKMTU0MTYwMzU4NA9kFggCAw8WAh4JaW5uZXJodG1sBUQ8aW1nIHNyYz0nLi4vaW1hZ2VzL25jbG9naW4uZ2lmJyBib3JkZXI9JzAnIFdJRFRIPScyNTAnIEhFSUdIVD0nMjknPmQCBQ8PFgIeBFRleHQFZVBsZWFzZSBlbnRlciB5b3VyIFVzZXIgSUQgYW5kIFBhc3N3b3JkPGJyPnRvIGFjY2VzcyBOZXRDbGFzc3Jvb20uIFByZXNzIHRoZSBMb2dpbiBidXR0b24gdG8gY29udGludWUuZGQCCQ8PFgIfAQVoPGI+VXJzdWxpbmUgQWNhZGVteTwvYj48QlI+MzQxIFNvdXRoIFNhcHBpbmd0b24gUm9hZDxCUj5TYWludCBMb3VpcyZuYnNwO01PJm5ic3A7NjMxMjI8QlI+KDMxNCkgOTg0LTI4MDBkZAILDw8WAh8BBWU8QSBIUkVGPSdodHRwOi8vd3d3LmJsYWNrYmF1ZC5jb20nIHRhcmdldD0nX3RvcCc+wqkxOTk3LTIwMDggQmxhY2tiYXVkLCBJbmMuIEFsbCByaWdodHMgcmVzZXJ2ZWQuPC9hPmRkZElubcQD6l6US/YZDvUEFRl9G53R");
$curl = curl_init(); curl_setopt($curl, CURLOPT_USERAGENT, $useragent); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($curl, CURLOPT_URL, "https://netclassroom.yourdomain.com:10443/NetClassroom7/Forms/login.aspx"); curl_setopt($curl, CURLOPT_VERBOSE, false); // Display communication with server curl_setopt($curl, CURLOPT_COOKIEJAR, $file); curl_setopt($curl, CURLOPT_COOKIEFILE, $file); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, "btnLogin=Login&sid=".$username."&pin=".$password."&__VIEWSTATE=".$viewstate); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
$store = curl_exec($curl);curl_close($curl);
$handle = fopen($file, "r"); $contents = fread($handle, filesize($file));if (preg_match("/\.ASPXFORMSAUTH/", $contents, $matches)) { echo "Sucessfull Login! <br />"; $_SESSION['student'] = 1;
}else { echo "Login Failed";}fclose($handle); if(file_exists("$file")) { unlink("$file"); }
?>