Webbrowser and Proxy Authorization

A

AGP

My project uses a Webbroswer control to navigate to certain websites and do
some processing on the info found there. However, my company has a proxy
server which I must authenticate through to get to the internet. I have
tried several methods to automate the signing in to the proxy server but
cant seem to get it to work properly. My credentials look like so:

Address: proxy.mycompany.com
Port: 80
UserID: billy
Pwd: bubba

Any suggestions eiyther through Vb6 or VB.NET on how I can programatically
sign into the proxy server using the webbrowser control?

Tia
AGP
 
C

Cor Ligthert[MVP]

AGP,

Your webbrowser is nothing more then the in your OS included webbrowser,
therefore you need to pass the proxy the same as you need for IE. Probably
the proxy does not see it as your webbrowser but just as IE.

Cor
 
A

AGP

cool i understand the part of it being a clone of my IE browser but there
has to be a way of automating the logon to the proxy server. Currenly it
presents me with a sign-in box and I just want to automate that part so I
can skip a step in my processing.

AGP
 
C

Cor Ligthert[MVP]

AGP

Then it is almost for sure a registry part. Probably it is easier to set
that by hand, while in a commercial application you are in my idea walking
on the edge by putting something for that in your program.

Cor
 
A

AGP

I dont belive it has to do anything with the regsitry. all you are doing is
passing the info to the browser but I just cant seem to make it work. also
its not a commerical application, its for my personal work process.
Something like this
http://support.microsoft.com/kb/q172998/
Although that doesnt handle a proxy address and port.

AGP
 
E

Ed

Can't you just copy the login page to a text file, change name, pass and
base URL to correct values, encrypt it for safety reasons, copy this to
a text box's property in the IDE (so it's saved when complied), then on
load in the program call,

Sub AutoLogin()
txt = De_Encyrption(Text1.Text) ' html code
WebBrowser1.Document.write (txt)
WebBrowser1.Document.Close
WebBrowser1.Document.Forms(0).Submit
End Sub

Ed
 
A

AGP

There is no logon page. This is a proxy server that I must authenticate
through to get to the external web. the logon is a pop-up input box for
userid and pwd.

AGP
 
S

Schmidt

AGP said:
I dont belive it has to do anything with the regsitry. all you are doing is
passing the info to the browser but I just cant seem to make it work. also
its not a commerical application, its for my personal work process.
Something like this
http://support.microsoft.com/kb/q172998/
Although that doesnt handle a proxy address and port.

The Link basically shows, what is needed.
If you have a ProxyIP, a ProxyPort and a Proxy-Usr+Pass
then the socket-connect of the request has to be made
on the ProxyIP and ProxyPort.
Additionally your http-Header has to be enhanced by
the following.
At the very first line of the http-Header:
(not sure, if you can manage/manipulate that inside the
navigate-method of the IE-Control)
Instead of the normal first line wich would be e.g.:
"Get /" & WebUrl & " HTTP/1.1"
you will have to send to the proxy the fully qualified Url
(including the domainname/IP of the "real WebHost"):
"Get http://" & DomainOrIP & "/" & WebUrl & " HTTP/1.1"
so that the proxy gets a chance, to parse the real target-
IP out, to wich to connect to (indirectly).

Additionally your http-header has to be enhanced by
this line:
"Authorization: Basic " & _
Base64Enc(ProxyUsr & ":" & ProxyPasswd)

Now your connect should go through.
At least this works for us, if we use the socketapi
directly.

Olaf

P.S. Here's some code for Base64Encoding:

Public Function Base64Enc(s$) As String
Static Enc() As Byte, Done as Boolean
Dim b() As Byte, Out() As Byte, i&, j&, L&
Const E="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
If Not Done Then Done = True: Enc = StrConv(E, vbFromUnicode)

L = Len(s): b = StrConv(s, vbFromUnicode)
ReDim Preserve b(0 To (UBound(b) \ 3) * 3 + 2)
ReDim Preserve Out(0 To (UBound(b) \ 3) * 4 + 3)
For i = 0 To UBound(b) - 1 Step 3
Out(j) = Enc(b(i) \ 4): j = j + 1
Out(j) = Enc((b(i + 1) \ 16) Or (b(i) And 3) * 16): j = j + 1
Out(j) = Enc((b(i + 2) \ 64) Or (b(i + 1) And 15) * 4): j = j + 1
Out(j) = Enc(b(i + 2) And 63): j = j + 1
Next i
For i = 1 To i - L: Out(UBound(Out) - i + 1) = 61: Next i
Base64Enc = StrConv(Out, vbUnicode)
End Function
 
A

AGP

Thank you for the info. I can pass a header to the web control but I cannot
manilpulate the first line of the command sent to the browser. at least i
dont think i can. i have tried sending the header just like in the sample
with my base64 encodong and nothing has worked.

AGP
 
S

Schmidt

AGP said:
Thank you for the info. I can pass a header to the web control but I cannot
manilpulate the first line of the command sent to the browser. at least i
dont think i can. i have tried sending the header just like in the sample
with my base64 encodong and nothing has worked.

Then you should just get the Bytes of the WebPages you are
interested in over Winsock.Ocx or pure socket-api.
If you need a DOM for parsing things out you could load
the Bytes (respective the String) into the IE-Control
after you got them over the "raw sockets", writing the
http-headers the way you need it (with your proxy in mind).

Olaf
 
A

AGP

Our group needs to see the page in a browser for manual checking and other
functions. So i have to stick with the webbrowser control.

AGP
 
S

Schmidt

Our group needs to see the page in a browser for manual
checking and other functions.
So i have to stick with the webbrowser control.
Sure, no problem with that.
I only say - don't navigate over the proxy directly with
the Browser-Control - just do it in two steps.
First load the Page over winsockets into a string -
then load this string (with its HTML-Content) into
the Control in a second step.

Olaf
 
H

Himanshu

I am looking for the exactly similar solution. I am using Web Bowser control
in my application and want use proxy auth. Please let me know if you have
found a solution.

Himanshu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top