如何在Delphi中打开带有http身份验证的url?

发布于 2024-12-09 02:23:26 字数 134 浏览 0 评论 0原文

如何以透明的方式打开需要“http 身份验证”传递登录名和密码的网址(浏览器窗口)? delphi 中的旧应用程序需要从 Reporting Services 打开“.aspx”格式的报表。

谢谢,塞尔索

How open a url (a browser window) that need "http authentication" passing login and password in a transparent way? The legacy app in delphi need open a report in ".aspx" from Reporting Services.

Thanks, Celso

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

分開簡單 2024-12-16 02:23:26

使用 Indy TidHTTP 组件,因为它可以轻松处理身份验证要求。将组件放在表单上,​​然后:

IdHTTP1.Request.UserName := 'xxx';
IdHTTP1.Request.Password := 'xxx';
IdHTTP1.Get(x);

我相信这适用于您可能拥有的任何 Indy 版本。

Use the Indy TidHTTP component as it can easily handle the authentication requirements. Drop the component on the form and:

IdHTTP1.Request.UserName := 'xxx';
IdHTTP1.Request.Password := 'xxx';
IdHTTP1.Get(x);

I believe that works for whatever Indy version that you might have.

感性 2024-12-16 02:23:26

您可以使用 WinHTTP,检查IWinHttpRequest.SetCredentials 方法

检查此示例

uses
  Variants,
  SysUtils,
  WinHttp_TLB;


Const
  HTTPREQUEST_SETCREDENTIALS_FOR_SERVER = 0;
Var
  Http: IWinHttpRequest;
begin
  try
   Http := CoWinHttpRequest.Create;
   try
     Http.Open('GET', 'http://Foo.com/home', False);
     Http.SetCredentials('AUser','APassword', HTTPREQUEST_SETCREDENTIALS_FOR_SERVER);
     Http.Send(EmptyParam);

     //Do your stuff

   finally
     Http:=nil;
   end;
  except
    on E:Exception do
      Writeln(E.Classname, ': ', E.Message);
  end;
end.

You can use WinHTTP, check the IWinHttpRequest.SetCredentials method

check this sample

uses
  Variants,
  SysUtils,
  WinHttp_TLB;


Const
  HTTPREQUEST_SETCREDENTIALS_FOR_SERVER = 0;
Var
  Http: IWinHttpRequest;
begin
  try
   Http := CoWinHttpRequest.Create;
   try
     Http.Open('GET', 'http://Foo.com/home', False);
     Http.SetCredentials('AUser','APassword', HTTPREQUEST_SETCREDENTIALS_FOR_SERVER);
     Http.Send(EmptyParam);

     //Do your stuff

   finally
     Http:=nil;
   end;
  except
    on E:Exception do
      Writeln(E.Classname, ': ', E.Message);
  end;
end.
三五鸿雁 2024-12-16 02:23:26

如果可以的话,您可以只拥有一个包含用户名和密码的 URL。

http://用户名:[电子邮件受保护]/page.aspx

you can just have an URL with the username and password in it if that is acceptable.

http://username:[email protected]/page.aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文