Automatically Login to a Protected Site (Using Authentication Dialog) like routers...
Hi - first time posting at this forum:wave: ,
i want to make a simple application - i tried to search the forum but nothing found...
Automatically Login to a Protected Site (Using Authentication Dialog) like routers... or protected directory (.htaccess)
Well as i am saying - i would like to connect with simple way like from address bar or making vb program (i have many wifi aps and i want to control them from a program in vb using webbrowser or winhttp)
i know that at ftp you can write at address bar of ie:
old days i think that you can use it too for http:// but - many times i tried and get nothing... :-(
So i am familiar with VB 6 / winhttp / webbrowser controls and if someone can help me with this prob i have will be cool!!!!
Thanx in advance
ps: @ moderators - i didn;t know acctually where to post this thread - i hope it will be at right section...
Re: Automatically Login to a Protected Site (Using Authentication Dialog) like routers...
Welcome to the Forums.
Are you going to be using VB6 for this then? If so I can move this thread to the Classic VB and Earlier forum.
Re: Automatically Login to a Protected Site (Using Authentication Dialog) like routers...
yes,
simple Classic VB6,
and sorry - please reply me the new link.
Thanx
Re: Automatically Login to a Protected Site (Using Authentication Dialog) like routers...
Re: Automatically Login to a Protected Site (Using Authentication Dialog) like routers...
Thread Moved
You can use the Inet control and pass the login information so you can download the page. Not sure what exactly you want to do after login.
Re: Automatically Login to a Protected Site (Using Authentication Dialog) like routers...
inet control can pass information at authentication dialog... is it possible ?
can i have an example... ?
- what i want to do?
i want for example resetting my Access Point (applying dchp for dlink 900ap - reset it fast) - every 1 hour ..
can u give me one example - please - thanks in advance.
Re: Automatically Login to a Protected Site (Using Authentication Dialog) like routers...
Re: Automatically Login to a Protected Site (Using Authentication Dialog) like routers...
Please don't bump your threads.
Re: Automatically Login to a Protected Site (Using Authentication Dialog) like routers...
.htaccess uses base 64 encoding.
Add two command buttons and a winsock control to a form:
Code:
Option Explicit
Dim MyIP
Dim MyPort
Dim MyUsername
Dim MyPassword
Dim MyCGI
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Command2_Click()
Winsock1.Close
Winsock1.RemotePort = MyPort
Winsock1.RemoteHost = MyIP
Winsock1.Connect
End Sub
Private Sub Form_Load()
MyIP = "192.168.0.1"
MyPort = "82"
MyUsername = "username"
MyPassword = "password"
MyCGI = "/cgi/some.cgi?params"
End Sub
Private Sub Form_Unload(Cancel As Integer)
Winsock1.Close
End Sub
Private Sub Winsock1_Connect()
With Winsock1
.SendData ("GET " & MyCGI & " HTTP/1.1" & vbCrLf)
.SendData ("Accept: */*" & vbCrLf)
.SendData ("Accept-Language: en-us" & vbCrLf)
.SendData ("Accept-Encoding: gzip, deflate" & vbCrLf)
.SendData ("User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)" & vbCrLf)
.SendData ("Host: HostNameGoesHere" & vbCrLf)
.SendData ("Connection: Keep-Alive" & vbCrLf)
.SendData ("Authorization: Basic " & Encode64(MyUsername & ":" & MyPassword) & vbCrLf)
.SendData (vbCrLf)
End With
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
Dim GotIt As String
Winsock1.GetData GotIt
MsgBox GotIt
End Sub
Function Encode64(InputStr As String) As String
Dim State As Integer
Dim i As Integer
Dim Base64
Dim current As Integer
Dim old As Integer
Dim first_new As String
Dim second_new As String
Dim Output As String
Base64 = Array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", _
"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", _
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", _
"n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", _
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+", "/")
For i = 1 To Len(InputStr)
State = State + 1
Select Case State
Case 1
current = Asc(Mid(InputStr, i, 1))
first_new = Base64((Int(current / 4) And &H3F))
Output = Output & first_new
Case 2
current = Asc(Mid(InputStr, i, 1))
first_new = Base64((((old * 16) And &H30) Or ((Int(current / 16) And &HF))))
Output = Output & first_new
Case 3:
current = Asc(Mid(InputStr, i, 1))
first_new = Base64((((old * 4) And &H3C) Or ((Int(current / 64) And &H3))))
second_new = Base64((current And &H3F))
Output = Output & first_new & second_new
State = 0
End Select
old = current
Next
Select Case State
Case 1
first_new = Base64(((old * 16) And &H30))
Output = Output & first_new & "=="
Case 2
first_new = Base64(((old * 4) And &H3C))
Output = Output & first_new & "="
End Select
Encode64 = Output
End Function
Re: Automatically Login to a Protected Site (Using Authentication Dialog) like routers...
this is something i think i need hmmm...
ill try this .. thanks