English 中文(简体)
Delphi soap https 认证失败
原标题:Delphi soap https authentication failure pops up a dialog box

我们有使用SOAP(THTTPRIO等)通信的德尔菲克斯XE应用,这些通信(在德尔菲特)在WinInet.dll(缺席)上运行。 我们确定了认证代码,以便它能够使用httpscreditation,当用户名称和密码正确时,一切都是罚款的。

问题是,如果认证细节不正确,你就会从Windows获得一个信息箱,而这个信箱很可能被WinInet.dll本身淹没。 我想让这一辩证箱消失。 我可以指出,如何改变我的《德尔菲斯行动计划》,以便通过口号胜出。

The situation is different than this question in the following ways:

  1. 我正在做所有事情,包括打电话(......)确定用户名称和密码。

  2. I am not using a server with a self-signed certificate, so the soIgnoreInvalidCerts flag is not applicable to my case.

  3. 在某种程度上,我认为,我需要从温得内网中接过一些APIC电话,以告诉它不要登上,即它有(一些窗口称Windows Security Options)来问用户。

  4. In my case the user name and password we have in our configuration file is being used, it is wrong (out of date) and so we want the WinInet code to simply return an error instead of popping up the dialog box.

Perhaps the other question the guy really did figure out how to do this, but the detail on that question is insufficient to see how he did it. The accepted answer does not work for me.

下面是:

WinInetMSDN docs for PLUGIN_AUTH_FLAGS_CAN_HANDLE_UI - that don t may be applicable to a WinInetuser, rather to a plugin.

WinInet MSDN docs discuss InternetSetOption, and some newsgroups have lead me to the following on-before-post event handler code:

procedure TMyDevice.HTTPWebNodeOnBeforePost(
  const HTTPReqResp: SOAPHTTPTrans.THTTPReqResp; Data: Pointer);
var
 SecurityFlagsLen:DWORD;
 SecurityFlags:DWORD;
begin
  { authentication, NTLM+HTTPS, WinInet authentication set via WinInet SET INTERNET OPTION API.
    This approach recommended on newsgroups for https basic authentication.  }

    if fUserName<>   then
   if not InternetSetOption(Data,
               INTERNET_OPTION_USERNAME,
               PChar(fUserName),
               Length(fUserName)) then
     raise EWebServiceAuthException.Create(SysErrorMessage(Windows.GetLastError));

   if fPassword<>   then
  if not InternetSetOption(Data,
               INTERNET_OPTION_PASSWORD,
               PChar(fPassword),
               Length (fPassword)) then
     raise EWebServiceAuthException.Create(SysErrorMessage(Windows.GetLastError));

      { possible type of hackage: WinInet Security option flags to stop password box? }
     SecurityFlagsLen := SizeOf(SecurityFlags);
      InternetQueryOption({Request}data, INTERNET_OPTION_SECURITY_FLAGS,
      Pointer(@SecurityFlags), SecurityFlagsLen);
      SecurityFlags := SecurityFlags or SECURITY_FLAG_something;
      InternetSetOption({Request}data, INTERNET_OPTION_SECURITY_FLAGS,
      Pointer(@SecurityFlags), SecurityFlagsLen);
end;

This code makes the password work, but when the user s entered password is wrong, how do I get the SOAP call to fail, or raise an exception, instead of popping up a message box?

最佳回答

WinINet改为WinHTTP。 两者都具有非常密切的APIC,而第2行并不产生任何国际不动产业联合会的互动,而是将退回错误代码,就像任何其他APIC一样。 WinINet的F部分对一些软件来说可能是一个好主意,但如不满足你的需要,它就象样。

当然,要以类似方式处理高频和高频频通信及认证问题。 但是,你必须迅速掌握用户名称和密码,并根据要求更新吉大港山区的头盔。 见

根据我们的测试, WinHTTP比WinINet要快得多(这当然是因为它不执行任何倡议部分,也不与因特网探索图书馆连接)。

You can take a look at our Open Source classes to guess how small is the difference in the API between WinINet and WinHTTP (most code is shared in the linked unit).

问题回答

Try modifying SOAPHTTPTrans to handle the error silently. In THTTPReqResp.HandleWinInetError, there is ultimately a call to the error dialog:

  Result := CallInternetErrorDlg

You can probably detect your particular error, you should be able to return a 0 from HandleWinInetError, or at least NOT make a call to CallInternetErrorDlg. See if that helps.





相关问题
determining the character set to use

my delphi 2009 app has a basic translation system that uses GNUGetText. i had used some win API calls to prepare the fonts. i thought it was working correctly until recently when someone from Malta ...

Help with strange Delphi 5 IDE problems

Ok, I m going nuts here. For the last (almost) four years, I ve been putting up with some extremely bad behavior from my Delphi 5 IDE. Problems include: Seemingly random errors in coride50.bpl ...

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How convert string to integer in Oxygene

In Delphi, there is a function StrToInt() that converts a string to an integer value; there is also IntToStr(), which does the reverse. These functions doesn t appear to be part of Oxygene, and I can ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签