0

问题:在我们的组织中,我们有一个用 c#/.Net2 编写的本地单点登录应用程序,它已经运行了多年。我们最近发现该应用程序无法与 Outlook Web Access 2010 一起使用。一些网络搜索出现了来自 SSO 供应商(Novell KBCitrix KB)的几篇文章,这些文章提到了这个问题。OWA2010 在提交时执行一个 javascript,添加一个名为“PBack=0”的 cookie,如果未包含在帖子中,将导致身份验证失败。

问题:如何在 SHDocVw.InternetExplorer 的 Navigate 方法中包含 cookie?

//ie2 is the instance of IE (SHDocVw.InternetExplorer) containing the OWA login page
ie2.Navigate(URLToPostTo, ref vFlags, ref vTarget, ref vPost, ref vHeaders);
4

1 回答 1

1

此 c# 代码在 Internet Explorer 中为 owa 2010 执行单点登录。

 AutoResetEvent documentCompleteOW2010;
    void OWA2010LaunchAndSSO()
    {
        var sURL "https://owaserver.yourorg.org/owalogon.asp?

        SHDocVw.InternetExplorer explorer = new SHDocVw.InternetExplorer();
        explorer.Visible = true;
        explorer.DocumentComplete += OnIEDocumentCompleteOWA2010; // Setting the documentComplete Event to false            
        documentCompleteOW2010 = new AutoResetEvent(false);
        object mVal = System.Reflection.Missing.Value;
        explorer.Navigate(sURL, ref mVal, ref mVal, ref mVal, ref mVal);// Waiting for the document to load completely            
        documentCompleteOW2010.WaitOne(5000);

        try
        {
            mshtml.HTMLDocument doc = (mshtml.HTMLDocument)explorer.Document;
            mshtml.HTMLInputElement userID = (mshtml.HTMLInputElement)doc.all.item("username", 0);
            userID.value = "someADUserName";

            mshtml.HTMLInputElement pwd = (mshtml.HTMLInputElement)doc.all.item("password", 0);

            pwd.value = "someADPassword";
            mshtml.HTMLInputElement btnsubmit = null;
            var yada = doc.getElementsByTagName("input");
            foreach (var VARIABLE in yada)
            {
                var u = (mshtml.HTMLInputElement)VARIABLE;
                if (u.type == "submit")
                {
                    btnsubmit = u;
                }
            }
            btnsubmit.click();

        }
        catch (Exception err)
        {
            //do something
        }
        finally
        {
            //remove the event handler
            explorer.DocumentComplete -= OnIEDocumentCompleteOWA2010;
        }
    }

    private void OnIEDocumentCompleteOWA2010(object pDisp, ref object URL)
    {
        documentCompleteOW2010.Set();
    }
于 2011-09-06T20:28:35.563 回答