Solved

Provide Authentication in Web Request of AxWebBrowser instance

Posted on 2007-12-06
5
257 Views
Last Modified: 2013-11-07
I am using the COM AxWebBrowser in a VS 2003 (1.1) project to access a password protected area of a website.  I need to pass a predefined auth so as not to burden the EU with auth'ing when they have already done so to use the app.  How do I pass that as part of the web request/flags/options?
0
Comment
Question by:dmoring
  • 2
5 Comments
 
LVL 18

Expert Comment

by:armoghan
ID: 20428993
One way is this.. That is how i login to yahoo.
Prerequisite is that you are not logged in already to yahoo.

To test.. Open in browser mail.yahoo.com
and you if you are already logged in, then sign out..

Then run the code which i have placed in the sample by changing your username and password string and you will automatically login to the mail of yahoo page
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        AxWebBrowser1.Navigate2("mail.yahoo.com")

    End Sub

    Dim bool As Boolean

    Private Sub AxWebBrowser1_DocumentComplete(ByVal sender As Object, ByVal e As AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent) Handles AxWebBrowser1.DocumentComplete

        If Not bool Then

            bool = True

            CType(CType(AxWebBrowser1.Document, mshtml.HTMLDocument).getElementById("username"), mshtml.HTMLInputElement).value = "yourusername"

            CType(CType(AxWebBrowser1.Document, mshtml.HTMLDocument).getElementById("passwd"), mshtml.HTMLInputElement).value = "yourpassword"

            CType(CType(AxWebBrowser1.Document, mshtml.HTMLDocument).getElementById("login_form"), mshtml.HTMLFormElement).submit()

        End If

    End Sub

Open in new window

0
 

Author Comment

by:dmoring
ID: 20429070
armoghan, thanks for your reply.  No, I'm not talking about forms-based auth, but the permissions based auth (i.e., the IE-based "popup" that occurs when the page is accessed).  Since I know that it is permissions-protected, it seems to me I can initiate a request with the auth in the post...
0
 
LVL 18

Accepted Solution

by:
armoghan earned 500 total points
ID: 20440097
you can also try the webclient or web request way to login
This thread may be useful in this regard
http://www.dotnet247.com/247reference/msgs/52/264260.aspx
0
 
LVL 1

Expert Comment

by:Computer101
ID: 20632927
Forced accept.

Computer101
EE Admin
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now