Discussion:
access password protected site error
(too old to reply)
George
2008-10-16 08:58:01 UTC
Permalink
Hello everyone,


Here is my test code. My question is even if I provide a wrong
username/password to access passport protected site, like login.live.com, the
return code will always be successful.

Anyone have any ideas what is wrong? :-)

[Code]
#include <string>
#include <iostream>
#include <exception>
#include <windows.h>
#include <wininet.h>
#include <fstream>
#include <conio.h>

using namespace std;

#pragma comment(lib,"wininet.lib")

int main(int argc, char* argv[])
{
HINTERNET hOpenHandle, hConnectHandle, hResourceHandle;
DWORD dwError, dwStatus;
DWORD dwStatusSize = sizeof(dwStatus);

hOpenHandle = InternetOpen("TestAgent",

INTERNET_OPEN_TYPE_PRECONFIG,
NULL, NULL, 0);

hConnectHandle = InternetConnect(hOpenHandle,
"login.live.com",
80,
"GeorgePassport",
"WrongPassword",

INTERNET_SERVICE_HTTP,
0,0);

hResourceHandle = HttpOpenRequest(hConnectHandle, "GET",
"/",
NULL, NULL,
NULL,

INTERNET_FLAG_KEEP_CONNECTION | INTERNET_FLAG_NO_CACHE_WRITE,
0);

BOOL fResult = HttpSendRequest(hResourceHandle, NULL, 0, NULL, 0);

if ( fResult == false )
{
cout<<"HttpSendRequest failed!"<<endl;
cout<<"GetLastError(): "<<::GetLastError()<<endl;
}

HttpQueryInfo(hResourceHandle, HTTP_QUERY_FLAG_NUMBER |
HTTP_QUERY_STATUS_CODE, &dwStatus,
&dwStatusSize, NULL);

switch (dwStatus)
{
case HTTP_STATUS_PROXY_AUTH_REQ: // Proxy Authentication
Required
case HTTP_STATUS_DENIED: // Server Authentication Required.
cout<< "auth failed!"<<endl;
break;
case HTTP_STATUS_OK:
cout<< "auth pass!"<<endl;
break;
default:
cout<< "what happens here?"<<endl;
break;
}

return 0;
}
[/Code]


thanks in advance,
George
Dan Mitchell
2008-10-17 17:14:21 UTC
Permalink
Post by George
Here is my test code. My question is even if I provide a wrong
username/password to access passport protected site, like
login.live.com, the return code will always be successful.
Anyone have any ideas what is wrong? :-)
That page doesn't use HTTP authentication, so you can always retrieve the
page itself -- you're not trying to log in, you're retrieving the login
page.

What you need to do is an appropriate HTTP POST, putting values into the
various bits of the form. See

http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.5

for the docs for HTTP POST; you'll need to work out the correct format
for the post for that particular page, probably the easiest way to do that
would be to use fiddler and watch exactly what a browser does.

-- dan
George
2008-10-17 18:01:01 UTC
Permalink
Thanks Dan!


I think the root cause is I am using the wrong page. I want to WinInet API
like I showed in my original post to access some .Net Passport protected web
site by providing legal .Net Passport username and password,

- Does WinInet API supports .Net Passport based authentication?

- Could you provide some URLs for me to make a test?


regards,
George
Dan Mitchell
2008-10-20 19:00:51 UTC
Permalink
Post by George
- Does WinInet API supports .Net Passport based authentication?
No. Passport is form-based, you have to use the forms to authenticate
against it. See http://dev.live.com/liveID/default.aspx for the APIs that
Microsoft want you to use.

-- dan
George
2008-10-21 04:28:01 UTC
Permalink
Thanks dan!


1.

Do you mean I should use this one? My purpose is to develop a client
application which could use valid .Net Passport credentials to get some data
from web,

Windows Live ID Client 1.0 SDK

http://www.microsoft.com/downloads/details.aspx?FamilyID=b5a78784-922d-4267-a6e9-5d2ecf1dced8&displaylang=en

2.

I noticed the web sites you recommended are identified as Live ID, not .Net
Passport.

- What are the differences between .Net Passport ID and Live ID from end
user perspective? (i.e. if a user has .Net Passport ID, could he login Live
ID authentication protected sites? if a user has Live ID, could he login .Net
Passport authentication protected sites?)

- For the Live SDK you recommended, could it also be used to login to .Net
Passport web sites?


regards,
George
Dan Mitchell
2008-10-21 15:55:04 UTC
Permalink
Post by George
Do you mean I should use this one? My purpose is to develop a client
application which could use valid .Net Passport credentials to get
some data from web,
Sorry, I don't actually know anything about this myself; I just googled a
bit and that's the link I came up with.
Post by George
- What are the differences between .Net Passport ID and Live ID from end
user perspective?

Again -- googling for ".net passport live id", the first hit is
www.passport.net, and on that page, it says "Windows Live ID works with
Passport Network sites".

-- dan
George
2008-10-22 05:47:01 UTC
Permalink
Hi dan,
Post by Dan Mitchell
Again -- googling for ".net passport live id", the first hit is
www.passport.net, and on that page, it says "Windows Live ID works with > Passport Network sites".
The site only mentions we can use .Net Passport ID and Live ID -- support
both. I have did search for quite some time, but find nothing formal
documents which mentions .Net Passport ID and Live ID are the same thing. Do
you have any related documents to prove that?


regards,
George
Dan Mitchell
2008-10-31 23:44:02 UTC
Permalink
Post by George
The site only mentions we can use .Net Passport ID and Live ID --
support both. I have did search for quite some time, but find nothing
formal documents which mentions .Net Passport ID and Live ID are the
same thing. Do you have any related documents to prove that?
Go to msdn.microsoft.com, search for "passport id live id", second result
is http://msdn.microsoft.com/en-us/library/bb288408.aspx :

"The Windows Live ID service represents the evolution of Microsoft
Passport into a world based on federation. Windows Live ID will be the
authentication system for all existing and future Microsoft online
services. Relying parties (Microsoft properties and those of close
partners) who have implemented Passport will be compatible with the
Windows Live ID service."
...
"End users have been offered an automatic upgrade path for using their
Passport accounts as Windows Live IDs."

-- dan

Dan Mitchell
2008-10-21 15:57:05 UTC
Permalink
Post by George
Do you mean I should use this one? My purpose is to develop a client
application which could use valid .Net Passport credentials to get
some data from web,
Oh, and also, you're in the wrong group here -- if you look through the
list of groups on this server for "passport", you'll find:

microsoft.public.fdtnservices.passport.sdk

which is probably a better place to ask.

-- dan
George
2008-10-22 05:47:01 UTC
Permalink
Yes Sir!


regards,
George
Loading...