Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Internet explorer Delphi SOAP调用显示IE登录对话框-如何防止?_Internet Explorer_Authentication_Dialog_Web Services_Delphi - Fatal编程技术网

Internet explorer Delphi SOAP调用显示IE登录对话框-如何防止?

Internet explorer Delphi SOAP调用显示IE登录对话框-如何防止?,internet-explorer,authentication,dialog,web-services,delphi,Internet Explorer,Authentication,Dialog,Web Services,Delphi,我们有两个申请。他们用SOAP协议调用一个网站 其中一人在我们的登录表单中询问登录数据;另一个是后台进程,调度任务。 他们都使用InternetSetOption进行基本身份验证 如果用户键入错误的用户名或密码,SOAP调用将显示一个IE对话框以再次获取用户名/密码 这不是我们的风格。 2.)对话框是“无限”的,它要求,只有成功或取消退出重新显示。 3.)我们无法控制,会出现多少次。 4.)在后台进程中,对话框会停止进程-这是至关重要的 所以我需要一些选项或事件来阻止IE登录对话框的显示 如果登

我们有两个申请。他们用SOAP协议调用一个网站

其中一人在我们的登录表单中询问登录数据;另一个是后台进程,调度任务。 他们都使用InternetSetOption进行基本身份验证

如果用户键入错误的用户名或密码,SOAP调用将显示一个IE对话框以再次获取用户名/密码

这不是我们的风格。 2.)对话框是“无限”的,它要求,只有成功或取消退出重新显示。 3.)我们无法控制,会出现多少次。 4.)在后台进程中,对话框会停止进程-这是至关重要的

所以我需要一些选项或事件来阻止IE登录对话框的显示

如果登录名/密码错误,程序必须在不显示IE对话框的情况下使用401中止

我该怎么做

请帮我写一些代码。谢谢大家!


一些代码片段。但我认为这没什么帮助。这是一个具有基本身份验证的简单SOAP调用。但是如果登录不正确,IE将显示他的对话框

type TWSRIO = class(THTTPRIO)
...
end;

procedure TWSRIO.OnBeforePost(const HTTPReqResp: THTTPReqResp; Data:Pointer);
begin
  if Auth_Mod = SCRBRIO_Auth_Basic then
  begin
    if not InternetSetOption(Data,INTERNET_OPTION_USERNAME,PChar(FAuth_LoginName), Length(FAuth_LoginName)) then
        raise Exception.Create(SysErrorMessage(GetLastError));
    if not InternetSetOption(Data, INTERNET_OPTION_PASSWORD, PChar(FAuth_Password), Length(FAuth_Password)) then
        raise Exception.Create(SysErrorMessage(GetLastError));
  end;
end;

procedure TForm1.Test;
begin
  RIO := TWSRIO.Create(Self);
  RIO.Auth_Mode := SCRBRIO_Auth_Basic;
  RIO.Auth_LoginName := xxx;
  RIO.Auth_Password := yyy;
  ...
  o := GetStockQueryResponderInterface(False, GetURL(), RIO);
  o.GetStockQuery(sArtNr)
  ...
end;
也许解决办法是:

function TMyRIO.MyWiniNetError(LastError: DWord; Request: Pointer): DWord;
var
    OWEProc: TWinInetErrorEvent;
begin
    // When the LastError is zero, we return same code what the dialog does on Cancel
    if LastError = 0 then
    begin
        Result := ERROR_SUCCESS;
        Exit;
    end;
    if Assigned(HTTPWebNode) then
    begin
        try
            // Save old proc and set to nil for Avoid infinite loop
            OWEProc := Self.HTTPWebNode.OnWinInetError;
            Self.HTTPWebNode.OnWinInetError := nil;
            try
                // Call the original handler
                Result := Self.HTTPWebNode.HandleWinInetError(LastError, Request, True);
            finally
                // Restore our handler 
                Self.HTTPWebNode.OnWinInetError := OWEProc;
            end;
        except
            on E: Exception do
            begin
                // On  error we log the problem
                LogThis(E.Message);
                Result := ERROR_SUCCESS;
                Exit;
            end;
        end;
    end else
    begin
        Result := ERROR_SUCCESS;
        Exit;
    end;
end;
我不知道我们会有什么副作用。
但有了这段代码,我就无法在错误的身份验证上获得Windows登录对话框。只是错误。

它看起来像是在收到401状态时自动调用的
THTTPRIO
。我不知道您是否可以更改该行为。我尝试搜索,但没有从应用程序端获得任何控制该行为的方法。如果可能,您可以尝试使用IE浏览器提供的进行检查和测试。这可能有助于避免问题。我是否需要编写“OnWinInetError”以避免问题?但正如我所见,我还没有办法回到正常的状态。例如:if(ErrorCode=ThisError),那么MyHandler else OriginalHandler。您是否使用我在前面的评论中建议的身份验证选项进行了测试?它起作用了吗?你能告诉我们,你得到了什么结果吗?匿名登录没有显示任何对话框。谢谢但问题是我不能强迫1200个用户(在250个不同的公司)使用这个选项。