Php .NET Passport

Ever tried to create a client area in PHP using .NET passport as your authentication method?

Personally I don't believe in .NET passports, a script like this can easily be used to capture passwords.

Here's a little example of how to get it running, it uses the CURL library to send requests.

 
function setRequest($url,$headers)
{
	if (function_exists('curl_init'))
	{
		$curl = curl_init();
		curl_setopt($curl, CURLOPT_URL, $url);
		curl_setopt($curl, CURLOPT_FAILONERROR, TRUE);
		curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
		curl_setopt($curl, CURLOPT_VERBOSE, FALSE);
		curl_setopt($curl, CURLOPT_HEADER,TRUE);
		curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
		curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
		$data = curl_exec($curl);
		curl_close($curl);
		return $data;
	}
	else die('Error: <a href="http://curl.haxx.se/">CURL Library</a> Not found!');
}
 
function Authentication($username, $password)
{
	$arr[] = "GET /rdr/pprdr.asp HTTP/1.0\\r\\n\\r\\n";
	$data = setRequest ("https://nexus.passport.com:443/rdr/pprdr.asp",$arr);
 
	if ($data)
	{
		preg_match("/DALogin=(.+?),/",$data,$matches);
		$split = explode("/",$matches[1]);
 
		$headers = array("GET /$split[1] HTTP/1.1\\r\\n", 
							"Authorization: Passport1.4 OrgVerb=GET,OrgURL=http://messenger.msn.com,sign-in=$username,pwd=$password");
 
		$data = setRequest("https://" . $split[0] . ":443/". $split[1], $headers);
 
		return ($data) ? TRUE : FALSE;
	}
	else
	{
		return FALSE;
	}	
}
 


Now to use it is quite simple (example below), I am planning to create a few example login systems once I get time.

 
	if (Authentication("username@hotmail.com","password"))
	{
		print "Authentication Success";
	}
	else
	{
		print "Authentication Failed";
	}
 






Comments



after authentication

Hi, how can I get user details (name, billing address, ..) from his account after this Authentication ?I need it to implement to PHP based e-shop.Thanks


Post comment

Name *
Email
Title
Body *
Security Code
*
* Required fields

Latest Posts

Top 5 posts

Simple WYSIWYG Editor


Creating a WYSIWYG textbox for your website is actually quite simple.
2007-02-01 12:00:00

Moving items between listboxes in ASP.net/PHP example


Move items between two listboxes in ASP.net(C#, VB.NET) and PHP
2008-06-12 17:07:43

Cross Browser Issues: Firefox Word Wrapping


Firefox word wrapping issues
2008-06-09 09:51:21

Populate a TreeView Control C#


Populate a TreeView control in a windows application.
2009-08-27 16:01:03

What time will bring



2007-02-22 12:00:00