简体   繁体   English

与SSPI的INDY TIdHttp集成安全身份验证问题

[英]INDY TIdHttp Integrated Security authentication issue with SSPI

I'm trying to call a web service hosted on IIS with Windows Authentication security applied. 我正在尝试调用IIS上托管的Web服务,并应用了Windows身份验证安全性。

I'm using Delphi XE with INDY 10 and the TIdHttp component. 我正在使用带有INDY 10的Delphi XE和TIdHttp组件。

I can successfully call the web service if I pass in a valid username and password but I would like to use Integrated Security so that it automatically uses the credentials from the calling thread and does not require the user to manually input their details. 如果我传入有效的用户名和密码,我可以成功调用Web服务,但我想使用Integrated Security,以便它自动使用来自调用线程的凭据,并且不需要用户手动输入其详细信息。

I've included IdAuthenticationSSPI in the uses clause and call the http request as: 我在uses子句中包含了IdAuthenticationSSPI,并将http请求调用为:

IdHttp1.Request.BasicAuthentication := False;
IdHttp1.HTTPOptions := [hoInProcessAuth];
// IdHttp1.Request.Username := '...'; // including this works
// IdHttp1.Request.Password := '...'; // including this works

IdHttp1.Get(myURL, myOutputStream);

My understanding is that with IdAuthenticationSSPI it will impersonate the user of the calling thread if no credentials are passed. 我的理解是,如果没有传递凭证,它将使用IdAuthenticationSSPI模拟调用线程的用户。

I've seen comments on the atozedsoftware.newsgroups website that suggest this is possible but unfortunately I get a "HTTP/1.1 401 Unauthorized". 我在atozedsoftware.newsgroups网站上看到了一些评论,建议这是可能的,但不幸的是我收到了“HTTP / 1.1 401 Unauthorized”。

Does anyone have any suggestions? 有没有人有什么建议?

Following on from Remy Lebeau's comment it appears this is not possible with INDY until a known issue is fixed. 根据Remy Lebeau的评论,在修复已知问题之前,看起来这是不可能的。

I've solved my issue in another way and I'll post it here in case anyone else is interested. 我已经用另一种方式解决了我的问题,我会在这里发布,以防其他人感兴趣。

First I imported the WinHTTP type library (C:\\Windows\\system32\\winhttp.dll) and added WinHttp_TLB to the uses clause. 首先,我导入了WinHTTP类型库(C:\\ Windows \\ system32 \\ winhttp.dll)并将WinHttp_TLB添加到uses子句中。

Then I used it like this: 然后我用它像这样:

var
    http: IWinHttpRequest;
    url: String;
begin
    url := 'my web service';
    http := CoWinHttpRequest.Create;
    try
        http.SetAutoLogonPolicy(0); // Enable SSO
        http.Open('GET', url, False);
        http.Send(EmptyParam);
        ShowMessage(http.ResponseText);
    finally
        http := nil;
    end;
end;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM