Changes to make SSPI NTLM Authentication work

Giganews Newsgroups
Subject: Changes to make SSPI NTLM Authentication work
Posted by:  Paul Klink (pbkremovelink@paremoveritechdotcom.au)
Date: Wed, 16 Mar 2005

Hi,

I finally got SSPI NTLM Authentication to work with Indy 10.  I have
listed the changes required below.  I have tested these in a small test
program (against Microsoft ISA) but the testing only focused on
Authentication.

Could someone review (or maybe test) these changes and if they seem ok,
could they be applied to the Indy 10 Source.

Note that I figured out most of these fixes by reviewing other people's
newsgroup posts on this problem.  All I did was work out a set of
changes based on these posts.

Thanks
Paul Klink

Changes to IdHttp.pas (1.65)
----------------------------

1) Add IdAuthenticationSSPI to implementation uses clause (approx line: 665)

2) Improve checking of Authentication in DoOnProxyAuthorization (approx
line: 1420- 1428)  This change also prevents reseting of SSPI NTLM
Authentication when subsequent 407 responses are received as part of the
authentication process.

Remove code from (inclusive)
    ProxyParams.Authentication := Auth.Create;
to
    ProxyParams.Authentication.Reset;

and replace with

    if Assigned(Auth) then
    begin
      ProxyParams.Authentication := Auth.Create;
    end;
  end;

  result := Assigned(ProxyParams.Authentication)
            and
            Assigned(OnProxyAuthorization);

  // Clear password and reset autorization if previous failed
  if (AResponse.FResponseCode = 407)
      and
      not (ProxyParams.Authentication is TIdSSPINTLMAuthentication) then
  begin
    ProxyParams.ProxyPassword := '';
    if Assigned(ProxyParams.Authentication) then
    begin
      ProxyParams.Authentication.Reset;
    end;

3) Set Response.KeepAlive in DoOnProxyAuthorization if necessary (approx
line: 1475)

After the line of code
    until false;
in DoOnProxyAuthorization, add the following lines of code:

    if Result then
    begin
      Response.KeepAlive := ProxyParams.Authentication.KeepAlive;
    end;

Changes to IdAuthenticationSSPI.pas (1.3)
-----------------------------------------

1) Fix up implementation uses (approx lines: 306 & 310)

IdCoreGlobal should be IdGlobalProtocols
IdResourceStrings should be IdResourceStringsProtocols

Replies