Sending Username and Password Info To Web Site

Posted on 1998-09-14
Last Modified: 2010-04-30
I am working on an application that visits a web site, parses the html looking for images, and downloads images above a certain size threshold.

The application works fine on any web site that does not require a username and a password.

What I want to do now is provide an interface to the user that allows them to enter the url of the web site they wish to visit, and optionally, the username and password to access the site. The username and password information can appear in several guises.

The most common is to provide a dialog box that requests this information. The next most common method is to display the username and password field on the web page itself. The third most common is the First Virtual (FV) ID which is composed of a single entry field displayed on the web page.

What I most need to know is how to submit the username and password when the web site requests it using the most common of the above methods; that of the dialog box.

I need to do this within my VB app. The urls and their associated usernames and passwords are stored on a table in the database. When the site is visited, the username and password will be retrieved and submited to the web site upon request. This will allow the user to visit a pay website, grab the images, and log off as quickly as possible. They do not have to sit at the keyboard or do anything else save for providing the url, the username, and the password.

Any help in solving this problem would be greatly appreciated.

Mike Trivisonno
Question by:mtriviso
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +3
LVL 14

Expert Comment

ID: 1434712
You have to use the SenKeys Method

   SendKeys UserName & "{TAB}"  
   SendKeys Password & "{TAB}"

Author Comment

ID: 1434713
I need to have more information than that.

For example, how do I detect when the web site is requesting this information? I need to know how to detect when the username and password are requested before I can use the SendKeys method.

Also, the iNet Control provides a username and password property. And I assume I would be using this instead of the SendKeys.

If you have done this sort of thing in the past, an example would be greatly appreciated.

LVL 14

Expert Comment

ID: 1434714
The username and password from Inet are used to connect by FTP. If you browse on FTP site, that's right.

By the way, I don't have any idea on how you could detect when you need to send username and password. I think you should create a collection of URL associated with username and password.
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.


Author Comment

ID: 1434715

That's what I really need to know: how to detect when the web site is asking for the username and password. In fact, this web site uses the dialog box method. Imagine writing a VB app that would be able to provide the username and password to log you on to Expert Exchange. That's what I need to do.

But, thanks for your input anyway.

Expert Comment

ID: 1434716
1. What happens if you provide UID and PWD in advance?

2. You should be able to detect that dialog box within VB and fill up appropriately.

Author Comment

ID: 1434717
1. The uid and pwd are stored on a table in the database. So they will be known in advance.

2. This is the problem. How do I detect that web site has requested the browser to display a dialog box? How do I detect that event provide the uid and pwd.

I have a method:
Public Sub Inet1_StateChanged(ByVal State As Integer)

It is in this method that I will need to trap the event. What I am looking to trap is the problem. States like GetPage and GetHeader are easy enough. But how to I trap the open dialog request?

Netscape, Opera, and Explorer obviously know how to trap this event. They are always displaying this uid/pwd dialog box. If these apps can do it then I figure I should be able to do it too.

Expert Comment

ID: 1434718

Author Comment

ID: 1434719
That's not my problem.

My problem is detecting when the site is requesting this information in the
Public Sub Inet1_StateChanged(ByVal State As Integer)

I need to know when the site is requesting this information before I can supply the uid and pwd.


Expert Comment

ID: 1434720
When the HTTP response header indicates a 401 status, the web server is saying that you are not authorized for the request.  It should also include a "WWW-authenticate:" field.  This lets you know when you need to send authentication information.

What else do you need?

Expert Comment

ID: 1434721
Please repost your rejected answer as the answer so mtriviso can award you the points.  I received the following message this morning:

jf26028 answered one of my questions correctly but I rejected his

Is it possible to award him the points?

Here is the url for the question.


Accepted Solution

jf26028 earned 200 total points
ID: 1434722

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month8 days, 10 hours left to enroll

617 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