Solved

Provide Authentication in Web Request of AxWebBrowser instance

Posted on 2007-12-06
5
259 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

808 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