Einzelnen Beitrag anzeigen

Benutzerbild von user0815
user0815

Registriert seit: 5. Okt 2007
331 Beiträge
 
Delphi XE2 Professional
 
#1

NTLM Authentication

  Alt 11. Sep 2017, 10:28
Hallo,
ich soll mich per NTLM Authentication mit einem Server verbinden um Daten zu erhalten.
Rufe ich die URL als einfachen HTTP Request auf, so erhalte ich vom Server:

Content-Type: text/html
Server: Microsoft-IIS/7.0
WWW-Authenticate: Negotiate
WWW-Authenticate: NTLM
X-Powered-By: ASP.NET

HTTP-Authentifizierungsschemen

So wie ich es bis jetzt mache funktioniert es nicht (kann Änderungen hier vor Ort leider auch nicht testen):

Delphi-Quellcode:
procedure TFormMain.SendXmlOrderRequest(var XMLDoc: IXMLDocument; Url: String);
var
  Response: String;
  Send: TStringStream;
begin
    Send := TStringStream.Create(Utf8Encode(XMLDoc.Xml.Text));

    IdHTTP.Request.BasicAuthentication := false;
    IdHTTP.Request.Username := '';
    IdHTTP.Request.Password := '';

    IdHTTP.Request.Host := 'devap3';
    IdHTTP.Request.ContentType := 'text/xml';
    IdHTTP.Request.Charset := 'utf-8';
    IdHTTP.Request.AcceptCharSet := 'utf-8';
    IdHTTP.Request.ContentLength := Send.Size;
    IdHTTP.Request.CustomHeaders.Values['SOAPAction'] := 'http://tempuri.org/CheckOrder';

    IdHTTP.HTTPOptions := [hoForceEncodeParams, hoInProcessAuth];
    IdHTTP.ProtocolVersion := pv1_1;
   
    try
      Response := IdHTTP.Post(Url, Send);
    except
      on E: Exception do
      begin
      MemoDebug.Lines.Append('Exception HTTP: ' + E.Message);
      // erhalte dies als Ausgabe
      // Exception HTTP: Operation abgebrochen
      end;
    end;
    IdHTTP.Disconnect;   
end;

procedure TFormMain.IdHTTPAuthorization(Sender: TObject; Authentication: TIdAuthentication; var Handled: Boolean);
begin
  Authentication.Username := FUsername;
  Authentication.Password := FPassword;

  MemoDebug.Lines.Append('onAuthorization: ' + Authentication.Authentication);
  // erhalte dies als Ausgabe
  // onAuthorization: NTLM TlRMTVNTUAAB7AAAB7IAAAgACAAgAA7ACgAKACgAAABET00wOTgxMERBREEwOTgxMDM=

  Handled := true;
end;

procedure TFormMain.IdHTTPSelectAuthorization(Sender: TObject; var AuthenticationClass: TIdAuthenticationClass;
  AuthInfo: TIdHeaderList);
begin
  AuthenticationClass := TIdNTLMAuthentication;
end;
Kann jemand erkennen was ich falsche mache?
Hat jemand evtl. ein funktionierendes Beispiel?

Grüße
user0815
  Mit Zitat antworten Zitat