These are chat archives for IndySockets/Indy

30th
Jun 2017
Justin
@klsyzzz
Jun 30 2017 01:52
hi there, just wondering is there an example for using TIdHTTP and NTLM Authentication in delphi?
elekgeek
@elekgeek
Jun 30 2017 01:53

@rlebeau fabulous, both work like a charm

thanks a lot

Justin
@klsyzzz
Jun 30 2017 01:53
I need to call a httpPost action from within Delphi and using NTLM auth
Remy Lebeau
@rlebeau
Jun 30 2017 01:57
@klsyzzz NTLM support in Indy is spotty at best. There are two different NTLM classes available for TIdHTTP - TIdNTLMAuthentication in IdAuthenticationNTLM.pas (portable but untested), and TIdSSPINTLMAuthentication in IdAuthenticationSSPI.pas (Windows only). In theory, you should be able to just add one of those units to your uses clause and let TIdHTTP handle the rest. In practice, .... umm, good luck? They either work or they don't. I have no way of testing either one, as I have no access to any HTTP servers that use NTLM
Justin
@klsyzzz
Jun 30 2017 01:59
thank you @rlebeau , I will have a try and let you know how it goes
Justin
@klsyzzz
Jun 30 2017 02:39
hi @rlebeau , I added IdAuthenticationNTLM.pas to my uses clause, and created an instance of TidHTTP, what I need to do next to enable NTLM auth? I didn't find any property on TidHTTP to select auth type, do I need to do the following:
auth := TIdNTLMAuthentication.Create;
IdHTTP1.AuthenticationManager.AddAuthentication(auth);
Remy Lebeau
@rlebeau
Jun 30 2017 05:16
@klsyzzz just add the unit to the uses clause to register the class with TIdHTTP. TIdHTTP should then automatically use the class on any server that supports NTLM (though you can use the TIdHTTP.OnSelectAuthorization event to make sure that is what TIdHTTP picks, if multiple authentications are supported and registered). Now put your NTLM credentials in the TIdHTTP.Request.UserName and TIdHTTP.Request.Password properties, and assign a TIdHTTP.OnAuthorization event handler to promt the user for new credentials if the initial credentials don't work
Justin
@klsyzzz
Jun 30 2017 06:19
thanks @rlebeau, having issues getting it work, will ask you further questions once I'm more clear with it.