我们有使用SOAP(THTTPRIO等)通信的德尔菲克斯XE应用,这些通信(在德尔菲特)在WinInet.dll(缺席)上运行。 我们确定了认证代码,以便它能够使用httpscreditation,当用户名称和密码正确时,一切都是罚款的。
问题是,如果认证细节不正确,你就会从Windows获得一个信息箱,而这个信箱很可能被WinInet.dll本身淹没。 我想让这一辩证箱消失。 我可以指出,如何改变我的《德尔菲斯行动计划》,以便通过口号胜出。
The situation is different than this question in the following ways:
我正在做所有事情,包括打电话(......)确定用户名称和密码。
I am not using a server with a self-signed certificate, so the soIgnoreInvalidCerts flag is not applicable to my case.
在某种程度上,我认为,我需要从温得内网中接过一些APIC电话,以告诉它不要登上
,即它有(一些窗口称Windows Security Options)来问用户。 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?