Solved

VB6 winsock and basic authentication

Posted on 2008-06-22
2
1,580 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_
[X]
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
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
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…

615 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