Zugriff auf .htaccess (Login-Frage)
-
Hiho,
habe ich in C++ bzw. mittels WinAPI die Chance auf meiner Website eine
Seite zu öffnen, die mittels .htaccess geschützt ist?Ich muss praktisch einen automatischen Login vornehmen.
-
Wenn die Datei auf deinem Rechner liegt, stört die .htaccess afaik nicht - dann kannst du dich ganz normal durch's Dateisystem durchhangeln. Wenn du die Datei über Web-Anbindung herunterladen willst, steht ein C++ Programm vor den selben Einschränkungen wie dein Browser - wenn die .htaccess den Zugriff blockiert, bekommst du nichts.
(wäre auch noch schöner, wenn man so einfach an den Sicherheitsmaßnahmen eines fremden Web-Servers vorbeikommen könnte)
-
hola
Fruggle schrieb:
Hiho,
habe ich in C++ bzw. mittels WinAPI die Chance auf meiner Website eine
Seite zu öffnen, die mittels .htaccess geschützt ist?Ich muss praktisch einen automatischen Login vornehmen.
ich versteh das so, das er auf 'seinem' webspace eine durch .htaccess geschuetzte datei hat, die er runterladen will. ich geh mal davon aus, das er dadurch auch die zugangsdaten kennen wird.
ich kenn mich da leider in der WinApi zuwenig aus, was die webfunktionen betrifft.
ich kann mir aber vorstellen, das es dafuer auch Api-funktionen geben wird.Meep Meep
-
Ich kann dir auch nur mit einem Link weiterhelfen (englisch):
http://www.codeguru.com/forum/archive/index.php/t-328384.htmlGefunden hab ichs bei Google mit "htaccess winapi" und dann erster Link. Da ist auch Verweis zu einer MS-Seite, brauchste aber eine Live-ID.
Hoffe das verletzt nicht Microsofts Copyright:
SUMMARY
You can use HttpSendRequestEx to send requests to a password-protected URL. This article outlines the different techniques you can use.
Back to the topMORE INFORMATION
This is the usual sequence of APIs used with HttpSendRequest: InternetConnect ()
HttpOpenRequest ()
HttpSendRequestEx ()
HttpEndRequest ()Method 1
If the user name and password are known before sending the request (that is, they don't have to be dynamically entered by the user), then user name and password can be supplied directly to the InternetConnect API. However, unlike HttpSendRequest, HttpSendRequestEx will not resubmit a request on its own after receiving the "401 Access Denied" status code from the server. Therefore, HttpEndRequest will fail with an ERROR_INTERNET_FORCE_RETRY error. This error message from HttpEndRequest indicates that the application must go back to HttpSendRequestEx and send all the buffers with InternetWriteFile again.
Back to the topMethod 2
If it is not possible to supply credentials in the InternetConnect API, then you must use the following steps: 1. Similarly to HttpSendRequest, the status code of the request may be determined by calling HttpQueryInfo (hRequest, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG). With HttpSendRequestEx, HttpQueryInfo must be called after HttpEndRequest, not after HttpSendRequestEx.
2. Valid credentials can be entered either with InternetErrorDlg() or by calling InternetSetOption with INTERNET_OPTION_USERNAME and INTERNET_OPTION_PASSWORD options.
3. Similarly to method 1, the application should go back toHttpSendRequestEx.Both of the methods above have a serious drawback: Because HttpSendRequestEx is used to send large amounts of data, resubmitting the entire data upon receiving the ERROR_INTERNET_FORCE_RETRY error or the 401 status code may waste network bandwidth and time. Method 3 is the preferred method of handling user authentication with HttpSendRequestEx:
Back to the topMethod 3
This method involves sending an auxiliary request for the URL via HttpSendRequest. Note that HttpSendRequestEx should be called on the same handle as HttpSendRequest. This will ensure that the request sent by HttpSendRequestEx will be sent over the connection authenticated by the first call to HttpSendRequest. Reusing the connection (using "Keep-Alive" connection) is necessary for NTLM (NT LAN manager authentication) support. To preserve bandwidth and time, neither request nor reply should have large amounts of data. The best way to accomplish this is to send the same type of request with HttpSendRequest as HttpSendRequestEx, but with the 0 content length.The following steps show how to use an auxiliary request. It assumes that large amounts of data need to be POSTed to /Scripts/Poster.exe URL:
hOpen = InternetOpen (...) hConnect = InternetConnect (hOpen, ...) // Note INTERNET_FLAG_KEEP_CONNECTION flag needed for NTLM hRequest = HttpOpenRequest (hConnect, "POST", "/scripts/poster.exe", lpszVersion, lpszReferer, lpszAcceptTypes, INTERNET_FLAG_KEEP_CONNECTION, dwContext) HttpSendRequest (hRequest, NULL, 0, NULL, 0); // at this point normal authentication logic can be used. If // credentials are supplied in InternetConnect, then Wininet will // resubmit credentials itself. See HttpDump Internet Client SDK sample // for more information. // Read all returned data with InternetReadFile () do { InternetReadFile (hRequest, ..., &dwSize); } while ( dwRead != 0); // Now send real request that will be send with HttpSendRequestEx. By // this time all authentication is done // Note that we are using the same handle as HttpSendRequest<BR/> Again: HttpSendRequestEx (hRequest, ...); do { InternetWriteFile() } while () ; // stop condition if ( !HttpEndRequest ()) { if ( ERROR_INTERNET_FORCE_RETRY == (dwError= GetLastError() ) ) { Goto again; } // handle other errors here }
Performing all the authentication in HEAD request causes WinInet to create an appropriate authorization header that is sent with a large request submitted by HttpSendRequestEx.
Quelle: http://support.microsoft.com/default.aspx?scid=kb;en-us;194700
-
Ja, es geht um eine Webseite deren Inhalt angezeigt werden soll.
User/Password sind mir bekannt(ist ja meine eigene Seite^^).
Mein Programm soll nur den Login automatisch vornehmen.Die Webseite wird zudem in meiner Anwendung
in einem Fensterbereich angezeigt.
-
nimm libcurl!!
-
Irgendwer meinen Post gelesen??
Steht doch da: Wenn HttpSendRequest fehlschlägt, dann InternetSetOption(hRequest, NTERNET_OPTION_USERNAME, pszUser, strlen(pszUser)+1 ); und InternetSetOption(hRequest, INTERNET_OPTION_PASSWORD, pszPass, strlenlen(pszPass) + 1); aufrufen, danach die Request nochmal schicken!! Was ist denn dadran so schwer??? 2 Zeilen mehr, na und??