Solved

VB6 winsock and basic authentication

Posted on 2008-06-22
2
1,512 Views
Last Modified: 2013-11-13
im using a winsock control and im trying to access a page that uses a basic authentication (the username and password prompt) and im trying to figure out how i send the login information to the server using a winsock control. additionally i should probably add a check to see if it logged in already or not, i have not been able to find anything to help me out. i even checked RFC2616.
0
Comment
Question by:MTec89_
2 Comments
 
LVL 17

Accepted Solution

by:
zzzzzooc earned 125 total points
ID: 21842815
You basically only need to append "Authorization: Basic [base64]" to your response where [base64] is the base64-encoded string "username:password". Pretty basic.

Base64 Example:
http://www.freevbcode.com/ShowCode.Asp?ID=1085

Example:
-----------------
Option Explicit
Private Sub Command1_Click()
    Winsock1.Connect "192.168.1.1", 80
End Sub
Private Sub Winsock1_Connect()
    Dim strGet As String
    Dim cls64 As New Base64
    Dim str64 As String
    str64 = cls64.Encode("admin:admin")
    Set cls64 = Nothing
    strGet = "GET / HTTP/1.1" & vbCrLf & _
             "Authorization: Basic " & str64 & vbCrLf & vbCrLf
    Call Winsock1.SendData(strGet)
End Sub
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    Dim strData As String
    Call Winsock1.GetData(strData)
    MsgBox strData
End Sub
0
 

Author Closing Comment

by:MTec89_
ID: 31469589
thanks
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

831 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