Board index » cppbuilder » TIdHTTP and Windows Authentication
Aladin J.
![]() CBuilder Developer |
Aladin J.
![]() CBuilder Developer |
TIdHTTP and Windows Authentication2008-02-07 11:48:15 PM cppbuilder42 Hi all, I am using Indy 9.0. I have a job which needs to get HTTP via Internet and some website has Windows Authentication. How can I solved the problem. Thanks. |
Remy Lebeau (TeamB)
![]() CBuilder Developer |
2008-02-08 01:41:38 AM
Re:TIdHTTP and Windows Authentication
"Aladin J." < XXXX@XXXXX.COM >wrote in message
QuoteI am using Indy 9.0. QuoteI have a job which needs to get HTTP via Internet and some |
Aladin J.
![]() CBuilder Developer |
2008-02-08 11:14:24 AM
Re:TIdHTTP and Windows Authentication
I am using Incdy 9.0.18.
I try 2 things as followings but they don't work. 1. By using http->Request->Username = "username"; http->Request->Password = "password"; 2. By Using http->OnAuthorization = MyHandler; ++++ void __fastcall MyHandler(TObject *Sender, TIdAuthentication *Authentication, bool &Handled) { Authentication->Username = "username"; Authentication->Password = "password"; Handled = true; } Anyway, if I change website on IIS to Basic Authentication, ther work. But when I use Windows Authentication, error 401 found. Aladin "Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message Quote
{smallsort} |
Remy Lebeau (TeamB)
![]() CBuilder Developer |
2008-02-12 01:51:02 AM
Re:TIdHTTP and Windows Authentication
"Aladin J." < XXXX@XXXXX.COM >wrote in message
QuoteI try 2 things as followings but they don't work. 1) register the desired TIdAuthentication... classes via the RegisterAuthenticationMethod() function at program startup. This allows TIdHTTP to select auth schemes automatically. 2) use the OnSelectAuthorization event to create a suitable TIdAuthentication... object instance for one of the auth schemes that the server supports (provided in the AuthInfo parameter of the event handler) 3) if you know the exact auth scheme that the server will be using ahead of time, you can assign a suitable TIdAuthentication... object instance to the Request->Authentication property before sending a request. Gambit |
Aladin J.
![]() CBuilder Developer |
2008-02-12 08:44:47 PM
Re:TIdHTTP and Windows Authentication
I try to use as followinng code but it generates error after I create
variable "IdNTLMAuthentication": The error is "Operation aborted". Where am I wrong? +++++ TIdNTLMAuthentication *IdNTLMAuthentication = new TIdNTLMAuthentication(); // Generates error "Operation aborted" IdNTLMAuthentication->Username = "user"; IdNTLMAuthentication->Password = "password"; http->Request->Authentication = IdNTLMAuthentication; "Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message Quote
|
Remy Lebeau (TeamB)
![]() CBuilder Developer |
2008-02-13 01:35:03 AM
Re:TIdHTTP and Windows Authentication
"Aladin J." < XXXX@XXXXX.COM >wrote in message
QuoteI try to use as followinng code but it generates error after I create QuoteIdNTLMAuthentication->Username = "user"; http->Request->Username = "user"; http->Request->Password = "password"; Gambit |
Aladin J.
![]() CBuilder Developer |
2008-02-13 11:14:31 AM
Re:TIdHTTP and Windows Authentication
Hi Gambit,
Thanks for your help. But when I call http->Request->Authentication = new TIdNTLMAuthentication(); It still found the error "Operation aborted." in Exception (ex.Message) after I have try/catch try { http->Request->Authentication = new TIdNTLMAuthentication(); } catch (ex as Exception) { ' Error Found in ex.Message() } Aladin "Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message Quote
|
Remy Lebeau (TeamB)
![]() CBuilder Developer |
2008-02-13 12:24:39 PM
Re:TIdHTTP and Windows Authentication
"Aladin J." < XXXX@XXXXX.COM >wrote in message
Quotehttp->Request->Authentication = new TIdNTLMAuthentication(); Quotecatch (ex as Exception) { catch (const Exception &ex) Gambit |
Aladin J.
![]() CBuilder Developer |
2008-02-13 02:34:06 PM
Re:TIdHTTP and Windows Authentication
I have already known the problem and solved. The first problem is OpenSSL is
not installed. Now I thought I can use NTLM Authentication. BUT it still have the error code returned from Web Server is "HTTP Error 401.2 - Unauthorized" I need just to find the way to Get HTTP Page from selected Windows Authentication from IIS server. How can I do? "Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message Quote
|
Remy Lebeau (TeamB)
![]() CBuilder Developer |
2008-02-13 03:24:20 PM
Re:TIdHTTP and Windows Authentication
"Aladin J." < XXXX@XXXXX.COM >wrote in message
QuoteBUT it still have the error code returned from Web Server of the original HTTP request and server reply? Gambit |
Aladin J.
![]() CBuilder Developer |
2008-02-13 09:35:54 PM
Re:TIdHTTP and Windows Authentication
I think it's NOT WORK.
Could you have a simple code to use TIdHttp with Windows Authentication? I need to Get HTTP page from IIS with having Windows Authentication. I'm surrender. "Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message Quote
|
Remy Lebeau (TeamB)
![]() CBuilder Developer |
2008-02-14 01:39:42 AM
Re:TIdHTTP and Windows Authentication
"Aladin J." < XXXX@XXXXX.COM >wrote in message
QuoteI think it's NOT WORK. client for. QuoteCould you have a simple code to use TIdHttp |
Aladin J.
![]() CBuilder Developer |
2008-02-14 05:48:52 AM
Re:TIdHTTP and Windows Authentication
I try to find program to capture HTTP header and fond it has nothing in HTTP
header when I call TIdNTLMAuthentication. Here is the HTTP Header when request: GET /default.html HTTP/1.1 Host: 127.0.0.1 Accept: text/html, */* User-Agent: Mozilla/4.0 (compatible; MSIE 5.0) Here is the HTTP Header when response: HTTP/1.1 401 Unauthorized Cache-Control: private Content-Type: text/html; charset=utf-8 Server: Microsoft-IIS/7.0 WWW-Authenticate: Negotiate WWW-Authenticate: NTLM X-Powered-By: ASP.NET Date: Wed, 13 Feb 2008 21:43:01 GMT Content-Length: 3481 I supprise in request caused by it should have more tag liked "Authorization: NTLM TlRMTVNTUAA..........." but it's gone. If you have a simple completed code for Windows Authentication. Pls send me at XXXX@XXXXX.COM that is appreaciated. Aladin J. "Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message Quote
|
Remy Lebeau (TeamB)
![]() CBuilder Developer |
2008-02-14 07:22:27 AM
Re:TIdHTTP and Windows Authentication
"Aladin J." < XXXX@XXXXX.COM >wrote in message
QuoteWWW-Authenticate: Negotiate However, since the server is also stating that "NTLM" is supported, then TIdNTLMAuthentication should have worked ok. Something else has to be happening. Since TIdNTLMAuthentication's constructor loads the OpenSSL DLLs, you probably don't have the right version installed. That is the only thing I can think of that would cause the constructor to throw an exception. QuoteI supprise in request caused by it should have more tag liked server replied asking for the credentials. There should have been a second request sent automatically after that which included the credentials that TIdNTLMAuthentication generates. Of course, if you can't create the TIdNTLMAuthentication object to begin with, then it won't be available to generate that data. Gambit |
Aladin J.
![]() CBuilder Developer |
2008-02-14 08:33:23 AM
Re:TIdHTTP and Windows Authentication
I try changing to use TIdSSPINTLMAuthentication instead BUT caused by the
package of Indy 9.0.xx does not provide for C++. I have to add IdAuthenticationSSPI.pas and IdSSPI.pas in Indy60.dpk first and the build new package which it works OK, no error found. But when I complied program by including <IdAuthenticationSSPI.hpp>there generates too many errors and I cannot fix them (Most in file IdSSPI.hpp and IdAuthenticationSSPI.hpp which automatically generated from compiler). Example error: IdSSPI.hpp(866): E2040 Declaration terminated incorrectly. IdSSPI.hpp(867): E2040 Declaration terminated incorrectly. IdAuthenticationSSPI.hpp(866): E2238 Multiple declaration for '_fastcall ESSPIException::ESSPIException(AnsiString,int)' Is this a right way to handle this task? Aladin J. "Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message Quote
|