Solved

VB6 winsock and basic authentication

Posted on 2008-06-22
2
1,476 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
Comment Utility
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_
Comment Utility
thanks
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
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.
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.

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now