🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.web
6 messages
6 total messages Started by Hipolito Lopez Thu, 24 Apr 2008 00:38
TIdHTTP Post error 401 Unauthorized
#103
Author: Hipolito Lopez
Date: Thu, 24 Apr 2008 00:38
36 lines
1992 bytes
I'm trying to do a post to a local url in my network using this
code, but I'm getting 401 error (HTTP/1.1 401 Unauthorized), what can I do? or search for? (the machine where I running this is out the domain)

    TMemoryStream *aStream = new TMemoryStream();
    TStringStream *StrStream = new TStringStream(NULL);

    TStringList *a = new TStringList();
    TIdURI *uri = new TIdURI("");
    TIdMultiPartFormDataStream *Params = new   TIdMultiPartFormDataStream();

    Params->AddFormField("tarjeta", codta);
    Params->AddFormField("tipo", tipo);
    Params->AddFormField("monto", monto);
    Params->AddFormField("cargo", cargo);
    Params->AddFormField("idcajero", idcajero);
    Params->AddFormField("cajero", cajero);

    IdHTTP1->Request->Clear();
    IdHTTP1->Request->BasicAuthentication = true;
    IdHTTP1->Request->Username = txtUser->Text;
    IdHTTP1->Request->Password = txtPwd->Text;

    IdHTTP1->Post(txtUrl->Text, Params, aStream);

    aStream->Seek(0, soFromBeginning);
    aStream->SaveToStream(StrStream);
    StrStream->Seek(0, soFromBeginning);

    ShowMessage(StrStream->DataString);

    delete a;
    delete aStream;
    delete Params;
    delete uri;
    delete StrStream;
Re: TIdHTTP Post error 401 Unauthorized
#104
Author: Remy Lebeau (TeamB)
Date: Thu, 24 Apr 2008 00:45
14 lines
1512 bytes
"Hipolito Lopez" <hlopezrd@gmail.com> wrote in message 
news:480fd69f$1@newsgroups.borland.com...

> I'm trying to do a post to a local url in my network using this
> code, but I'm getting 401 error (HTTP/1.1 401 Unauthorized),
> what can I do?

The server requires authentication that you are not providing.  Make sure 
you have included the appropriate IdAuthentication...hpp header file into 
your code, such as IdAuthenticationDigest.hpp.


Gambit 
Re: TIdHTTP Post error 401 Unauthorized
#105
Author: Hipolito Lopez
Date: Thu, 24 Apr 2008 01:08
5 lines
1036 bytes
Thanks Remy for you help.
But how do I know where file (header) to use?
"Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> wrote:
>you have included the appropriate IdAuthentication...hpp header file into 
Re: TIdHTTP Post error 401 Unauthorized
#106
Author: Remy Lebeau (TeamB)
Date: Thu, 24 Apr 2008 16:56
13 lines
1530 bytes
"Hipolito Lopez" <hlopezrd@gmail.com> wrote in message 
news:480fdd93$1@newsgroups.borland.com...

> But how do I know where file (header) to use?

Well, first you need to find out which authentication(s) the server supports 
in the first place.  After the server's reply comes back, you can look in 
the Response->WWWAuthenticate property to see which authentication(s) the 
server asked for.


Gambit 
Re: TIdHTTP Post error 401 Unauthorized
#107
Author: Hipolito Lopez
Date: Sat, 26 Apr 2008 04:01
22 lines
1492 bytes
Hi Remy,
>Well, first you need to find out which authentication(s) the server supports 
>in the first place.
The server send this to me:

HTTP/1.1 401 Unauthorized
Content-Length: 1539
Content-Type: text/html
Server: Microsoft-IIS/6.0
WWW-Authenticate: Negotiate
WWW-Authenticate: NTLM
MicrosoftOfficeWebServer: 5.0_Pub
X-Powered-By: ASP.NET
Date: Sat, 26 Apr 2008 03:37:40 GMT
Connection: close

I see that is using NTML, but I don't know what is 
WWW-Authenticate: Negotiate


What can I do?
Re: TIdHTTP Post error 401 Unauthorized
#108
Author: Remy Lebeau (TeamB)
Date: Mon, 28 Apr 2008 17:07
15 lines
1662 bytes
"Hipolito Lopez" <hlopezrd@gmail.com> wrote in message 
news:4812a935$1@newsgroups.borland.com...

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

You did not say which version of Indy you are using.  Indy 9 does not 
support "Negotiate" at all, but it does support ""NTLM".  Indy 10 supports 
both.  Both Indy 9 and 10 have IdAuthenticationSSPI ("NTLM" in Indy 9, 
"Negotiate" and "NTLM" in Indy 10) and IdAuthenticationNTLM (just "NTLM" in 
both) units available.


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