George
2008-10-16 08:58:01 UTC
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
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