Click to See Complete Forum and Search --> : Accessing a .htaccess directory using WinInet


KaramChand03
February 12th, 2005, 09:12 AM
Hello,

I want to access a .htaccess protected file at:

http://www.webyog.com/tempaccess/SQLyogTunnel.php

Username and password for the above site is:

Username: ritesh
password: ritesh

To connect I am doing the following sequence:

m_InternetSession = InternetOpen ( "MyApp", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0 );
if ( !m_InternetSession )
return false;

m_InternetConnect = InternetConnect ( m_InternetSession, m_HostName, m_Port, m_UserName, m_Password, INTERNET_SERVICE_HTTP, 0L, 0L );
if ( !m_InternetConnect )
return false;

m_HttpOpenRequest = HttpOpenRequest( m_InternetConnect, "POST", m_FileName, NULL, NULL, NULL, flags, 0L );
if ( !m_HttpOpenRequest )
return false;


In InternetConnect, the m_UserName and m_Password are correctly given to be "ritesh" and "ritesh".

After this I correctlypost my data using HttpSendRequestEx() and InternetWritefile(). Then I need to initiate the end by using HttpEndRequest()... the function returns FALSE.

When doing HttpQueryInfo().. I get a status code of HTTP_STATUS_DENIED. I call:


InternetErrorDlg ( GetDesktopWindow(), m_HttpOpenRequest, ERROR_INTERNET_INCORRECT_PASSWORD,
FLAGS_ERROR_UI_FILTER_FOR_ERRORS | FLAGS_ERROR_UI_FLAGS_GENERATE_DATA | FLAGS_ERROR_UI_FLAGS_CHANGE_OPTIONS,
NULL);


But it always returns ERROR_INTERNET_FORCE_RETRY.

Furthermore, even if I use URL like:

http://ritesh:ritesh@www.webyog.com/tempaccess/SQLyogTunnel.php

I am never able to login. But the above link correctly works with IE and FireFox.

I am sure I am doing something wrong? Can somebody help?

Any sample code will be best :)

Regards,
Karam

KaramChand03
February 12th, 2005, 11:54 PM
Anybody?

Since this is Win32 based, maybe somebody from that forum might help?

Mick
February 13th, 2005, 12:07 AM
Try this (http://support.microsoft.com/default.aspx?scid=kb;en-us;194700)

Mick
February 13th, 2005, 12:09 AM
< moved thread >

KaramChand03
February 13th, 2005, 02:48 AM
Thanks.

I will just check the link and let you know.

KaramChand03
February 13th, 2005, 02:17 PM
Thanks everybody.

I was able to solve the problem using help from the following link:

http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/samples/internet/networking/httpdump/default.asp