🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.socket
16 messages
16 total messages Started by Aladin J. Thu, 07 Feb 2008 15:48
TIdHTTP and Windows Authentication
#436
Author: Aladin J.
Date: Thu, 07 Feb 2008 15:48
8 lines
1002 bytes
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. 
Re: TIdHTTP and Windows Authentication
#437
Author: Remy Lebeau (TeamB)
Date: Thu, 07 Feb 2008 17:41
16 lines
1321 bytes
"Aladin J." <j_aladin@hotmail.com> wrote in message 
news:47ab27fc@newsgroups.borland.com...

> I am using Indy 9.0.

Which build number, though?

> I have a job which needs to get HTTP via Internet and some
> website has Windows Authentication. How can I solved
> the problem.

By "Windows Authentication", are you referring to NTLM?


Gambit 
Re: TIdHTTP and Windows Authentication
#438
Author: Aladin J.
Date: Fri, 08 Feb 2008 03:14
46 lines
2083 bytes
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)" <no.spam@no.spam.com> wrote in message 
news:47ab4352$1@newsgroups.borland.com...
>
> "Aladin J." <j_aladin@hotmail.com> wrote in message 
> news:47ab27fc@newsgroups.borland.com...
>
>> I am using Indy 9.0.
>
> Which build number, though?
>
>> I have a job which needs to get HTTP via Internet and some
>> website has Windows Authentication. How can I solved
>> the problem.
>
> By "Windows Authentication", are you referring to NTLM?
>
>
> Gambit
> 
Re: TIdHTTP and Windows Authentication
#442
Author: Remy Lebeau (TeamB)
Date: Mon, 11 Feb 2008 17:51
23 lines
1949 bytes
"Aladin J." <j_aladin@hotmail.com> wrote in message 
news:47abc8cd@newsgroups.borland.com...

> I try 2 things as followings but they don't work.

To use an Authentication scheme with TIdHTTP, one of the following things 
must be done:

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 
Re: TIdHTTP and Windows Authentication
#443
Author: Aladin J.
Date: Tue, 12 Feb 2008 12:44
43 lines
2527 bytes
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)" <no.spam@no.spam.com> wrote in message 
news:47b08ae4$1@newsgroups.borland.com...
>
> "Aladin J." <j_aladin@hotmail.com> wrote in message 
> news:47abc8cd@newsgroups.borland.com...
>
>> I try 2 things as followings but they don't work.
>
> To use an Authentication scheme with TIdHTTP, one of the following things 
> must be done:
>
> 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
> 
Re: TIdHTTP and Windows Authentication
#444
Author: Remy Lebeau (TeamB)
Date: Tue, 12 Feb 2008 17:35
22 lines
1697 bytes
"Aladin J." <j_aladin@hotmail.com> wrote in message 
news:47b19477@newsgroups.borland.com...

> I try to use as followinng code but it generates error after I create 
> variable "IdNTLMAuthentication":
>
> The error is "Operation aborted".

On which line exactly?

> IdNTLMAuthentication->Username = "user";
> IdNTLMAuthentication->Password = "password";

Don't do that.  Use TIdHTTP's properties instead:

    http->Request->Authentication = new TIdNTLMAuthentication();
    http->Request->Username = "user";
    http->Request->Password = "password";


Gambit 
Re: TIdHTTP and Windows Authentication
#445
Author: Aladin J.
Date: Wed, 13 Feb 2008 03:14
46 lines
2236 bytes
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)" <no.spam@no.spam.com> wrote in message 
news:47b1d8a6$1@newsgroups.borland.com...
>
> "Aladin J." <j_aladin@hotmail.com> wrote in message 
> news:47b19477@newsgroups.borland.com...
>
>> I try to use as followinng code but it generates error after I create 
>> variable "IdNTLMAuthentication":
>>
>> The error is "Operation aborted".
>
> On which line exactly?
>
>> IdNTLMAuthentication->Username = "user";
>> IdNTLMAuthentication->Password = "password";
>
> Don't do that.  Use TIdHTTP's properties instead:
>
>    http->Request->Authentication = new TIdNTLMAuthentication();
>    http->Request->Username = "user";
>    http->Request->Password = "password";
>
>
> Gambit
> 
Re: TIdHTTP and Windows Authentication
#446
Author: Remy Lebeau (TeamB)
Date: Wed, 13 Feb 2008 04:24
19 lines
1635 bytes
"Aladin J." <j_aladin@hotmail.com> wrote in message
news:47b2604f@newsgroups.borland.com...

> http->Request->Authentication = new TIdNTLMAuthentication();
>
> It still found the error "Operation aborted." in Exception (ex.Message)

What is the actual class type of the exception?

> catch (ex as Exception) {

That is not a valid statement.  You need to catch exceptions by reference,
preferrably by 'const' reference, ie:

    catch (const Exception &ex)


Gambit
Re: TIdHTTP and Windows Authentication
#447
Author: Aladin J.
Date: Wed, 13 Feb 2008 06:34
37 lines
2099 bytes
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)" <no.spam@no.spam.com> wrote in message 
news:47b27339$1@newsgroups.borland.com...
>
> "Aladin J." <j_aladin@hotmail.com> wrote in message
> news:47b2604f@newsgroups.borland.com...
>
>> http->Request->Authentication = new TIdNTLMAuthentication();
>>
>> It still found the error "Operation aborted." in Exception (ex.Message)
>
> What is the actual class type of the exception?
>
>> catch (ex as Exception) {
>
> That is not a valid statement.  You need to catch exceptions by reference,
> preferrably by 'const' reference, ie:
>
>    catch (const Exception &ex)
>
>
> Gambit
>
> 
Re: TIdHTTP and Windows Authentication
#448
Author: Remy Lebeau (TeamB)
Date: Wed, 13 Feb 2008 07:24
13 lines
1688 bytes
"Aladin J." <j_aladin@hotmail.com> wrote in message
news:47b28f19@newsgroups.borland.com...

> BUT it still have the error code returned from Web Server
> is "HTTP Error 401.2 - Unauthorized"

Then either your credentials are not correct, or the server does not want
NTLM authentication to begin with.  Can you show a log from a packet capture
of the original HTTP request and server reply?


Gambit
Re: TIdHTTP and Windows Authentication
#449
Author: Aladin J.
Date: Wed, 13 Feb 2008 13:35
27 lines
2232 bytes
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)" <no.spam@no.spam.com> wrote in message 
news:47b29d49$1@newsgroups.borland.com...
>
> "Aladin J." <j_aladin@hotmail.com> wrote in message
> news:47b28f19@newsgroups.borland.com...
>
>> BUT it still have the error code returned from Web Server
>> is "HTTP Error 401.2 - Unauthorized"
>
> Then either your credentials are not correct, or the server does not want
> NTLM authentication to begin with.  Can you show a log from a packet 
> capture
> of the original HTTP request and server reply?
>
>
> Gambit
>
> 
Re: TIdHTTP and Windows Authentication
#450
Author: Remy Lebeau (TeamB)
Date: Wed, 13 Feb 2008 17:39
17 lines
1783 bytes
"Aladin J." <j_aladin@hotmail.com> wrote in message 
news:47b2f1f8$1@newsgroups.borland.com...

> I think it's NOT WORK.

You did not provide the data I asked for.  Please do so.  I cannot help you 
further without it.  I need to see what the server is actually asking your 
client for.

> Could you have a simple code to use TIdHttp
> with Windows Authentication?

I already have.


Gambit 
Re: TIdHTTP and Windows Authentication
#451
Author: Aladin J.
Date: Wed, 13 Feb 2008 21:48
48 lines
2937 bytes
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 j_aladin@hotmail.com that is appreaciated.

Aladin J.

"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message 
news:47b32b3f$2@newsgroups.borland.com...
>
> "Aladin J." <j_aladin@hotmail.com> wrote in message 
> news:47b2f1f8$1@newsgroups.borland.com...
>
>> I think it's NOT WORK.
>
> You did not provide the data I asked for.  Please do so.  I cannot help 
> you further without it.  I need to see what the server is actually asking 
> your client for.
>
>> Could you have a simple code to use TIdHttp
>> with Windows Authentication?
>
> I already have.
>
>
> Gambit
> 
Re: TIdHTTP and Windows Authentication
#452
Author: Remy Lebeau (TeamB)
Date: Wed, 13 Feb 2008 23:22
28 lines
2629 bytes
"Aladin J." <j_aladin@hotmail.com> wrote in message 
news:47b3658e@newsgroups.borland.com...

> WWW-Authenticate: Negotiate
> WWW-Authenticate: NTLM

The server is asking for "Negotiate" first.  You have to use 
TIdSSPINTLMAuthentication instead of TIdNTLMAuthentication for that. 
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.

> I supprise in request caused by it should have more tag liked 
> "Authorization: NTLM TlRMTVNTUAA..........." but it's gone.

TIdHTTP does not send authorization credentials unless the server 
explicitally asks for them first.  In this case, you sent a request, and the 
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
Re: TIdHTTP and Windows Authentication
#453
Author: Aladin J.
Date: Thu, 14 Feb 2008 00:33
53 lines
3885 bytes
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)" <no.spam@no.spam.com> wrote in message 
news:47b37b92$1@newsgroups.borland.com...
>
> "Aladin J." <j_aladin@hotmail.com> wrote in message 
> news:47b3658e@newsgroups.borland.com...
>
>> WWW-Authenticate: Negotiate
>> WWW-Authenticate: NTLM
>
> The server is asking for "Negotiate" first.  You have to use 
> TIdSSPINTLMAuthentication instead of TIdNTLMAuthentication for that. 
> 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.
>
>> I supprise in request caused by it should have more tag liked 
>> "Authorization: NTLM TlRMTVNTUAA..........." but it's gone.
>
> TIdHTTP does not send authorization credentials unless the server 
> explicitally asks for them first.  In this case, you sent a request, and 
> the 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
>
> 
Re: TIdHTTP and Windows Authentication
#462
Author: Aladin J.
Date: Wed, 20 Feb 2008 11:44
58 lines
4108 bytes
Anybody help ??

"Aladin J." <j_aladin@hotmail.com> wrote in message 
news:47b38c15@newsgroups.borland.com...
>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)" <no.spam@no.spam.com> wrote in message 
> news:47b37b92$1@newsgroups.borland.com...
>>
>> "Aladin J." <j_aladin@hotmail.com> wrote in message 
>> news:47b3658e@newsgroups.borland.com...
>>
>>> WWW-Authenticate: Negotiate
>>> WWW-Authenticate: NTLM
>>
>> The server is asking for "Negotiate" first.  You have to use 
>> TIdSSPINTLMAuthentication instead of TIdNTLMAuthentication for that. 
>> 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.
>>
>>> I supprise in request caused by it should have more tag liked 
>>> "Authorization: NTLM TlRMTVNTUAA..........." but it's gone.
>>
>> TIdHTTP does not send authorization credentials unless the server 
>> explicitally asks for them first.  In this case, you sent a request, and 
>> the 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
>>
>>
> 
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads