如何使用 SHDocVw.InternetExplorer.Navigate 在 POST 中发送 cookie?

发布于 2024-11-26 11:47:57 字数 703 浏览 2 评论 0原文

问题: 在我们的组织中,我们有一个用 c#/.Net2 编写的自制单点登录应用程序,该应用程序已经运行了多年。我们最近发现该应用程序无法与 Outlook Web Access 2010 一起使用。一些 Web 搜索发现了 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);

Problem:
In our organization we have a home grown single-sign-on app written in c#/.Net2 that has been working for years. We recently found that the app doesn’t work with Outlook Web Access 2010. A few web searches turned up a couple articles from SSO vendors (Novell KB and Citrix KB) that refer to the issue. OWA2010 executes a javascript on submit that adds a cookie called “PBack=0” that if not included in the post will result in an authentication failure.

Question:
How can I include a cookie in the Navigate method of SHDocVw.InternetExplorer?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尐籹人 2024-12-03 11:47:57

此 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();
    }

This c# code performs single sign on for owa 2010 in Internet explorer.

 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();
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文