uses
[...]
IdBaseComponent,
IdGlobal, IdComponent, IdTCPConnection, IdTCPClient, IdHTTP,
IdAuthentication, IdException, IdAuthenticationSSPI, IdHeaderList;
[...]
procedure TForm1.ButtonDoRequestClick(Sender: TObject);
var IdHttp: TIdHttp;
begin
// https://stackoverflow.com/questions/32075389/indy-https-get-authentication
// https://github.com/IndySockets/OpenSSL-Binaries
// https://stackoverflow.com/questions/12056951/401-with-indy-idhttp-digest-authentication-in-delphi-xe
// Version bundled with XE8: 10.6.2.5263 -> not working against Apache with mod_auth_ntlm_winbind
// git checkout c7d5e086adeeb63c4db0d41c2791085bec9e1e27 / 2021-07-13 -> working
IdHttp := TIdHttp.Create(
nil);
IdHttp.Request.Clear;
IdHttp.Request.BasicAuthentication := false;
IdHttp.HTTPOptions := idHttp.HTTPOptions + [hoInProcessAuth];
// WICHTIG!
IdHttp.OnSelectAuthorization := IdHTTPSelectAuthorization;
MemoHttpGetResult.Lines.Clear;
try
try
MemoHttpGetResult.Lines.Add(IdHttp.Get('
http://testserver.example.org/ntlm/'));
except
// see also
// https://stackoverflow.com/questions/13950676/how-to-check-url-with-idhttp
on E: EIdException
do begin
MemoHttpGetResult.Lines.Add('
Indy raised an exception!');
MemoHttpGetResult.Lines.Add('
Exception class: ' + E.ClassName);
MemoHttpGetResult.Lines.Add('
Error message: ' + E.
Message);
end;
else
MemoHttpGetResult.Lines.Add('
An exception occured!');
end;
finally
IdHttp.Free;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
// in git checkouts of master branch BuildVersion is always 0
LabelIndyVersion.Caption:=IntToStr(gsIdVersionMajor) + '
.' +
IntToStr(gsIdVersionMinor) + '
.' +
IntToStr(gsIdVersionRelease) + '
.' +
IntToStr(gsIdVersionBuild);
end;
procedure TForm1.IdHTTPSelectAuthorization(Sender: TObject;
var AuthenticationClass: TIdAuthenticationClass; AuthInfo: TIdHeaderList);
begin
AuthenticationClass := TIdSSPINTLMAuthentication;
end;