Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VB6 winsock and basic authentication

Posted on 2008-06-22
2
Medium Priority
?
1,632 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 500 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
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 technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

916 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