Solved

VB6 winsock and basic authentication

Posted on 2008-06-22
2
1,556 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

734 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