0

問題: 私たちの組織には、c#/.Net2 で書かれた自家製のシングル サインオン アプリがあり、何年も機能しています。最近、アプリが Outlook Web Access 2010 で動作しないことがわかりました。いくつかの Web 検索で、この問題を参照するSSO ベンダー ( Novell KBおよびCitrix KB ) からの記事がいくつか見つかりました。OWA2010 は送信時に JavaScript を実行し、「PBack=0」と呼ばれる Cookie を追加します。この 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 に答える