<%
Option Explicit
Dim strLogin
strLogin = split(Base64Decode(replace(request.servervariables("HTTP_AUTHORIZATION"),"Basic ","")),":")
response.write("User="& request.ServerVariables("AUTH_USER") )
response.End()
'response.write "Login Name: " & strLogin(0) & ""
'response.write "Login Password: " & strLogin(1) & ""
Function Base64Decode(base64String)
Const Base64CodeBase = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
Dim dataLength, Out, groupBegin
dataLength = Len(base64String)
Out = ""
If dataLength Mod 4 <> 0 Then
Err.Raise 1, "Base64Decode", "Bad Base64 string."
Exit function
End if
' Now decode each group:
For groupBegin = 1 To dataLength Step 4
Dim numDataBytes, CharCounter, thisChar, thisData, groupData
' Each data group encodes up To 3 actual
' bytes.
numDataBytes = 3
groupData = 0
For CharCounter = 0 To 3
' Convert each charac
' ter into 6 bits of data, And add it To
' an integer For temporary storage. If a
' character is a '=', there
' is one fewer data byte. (There can onl
' y be a maximum of 2 '=' In
' the whole string.)
thisChar = Mid(base64String, groupBegin + CharCounter, 1)
If thisChar = "=" Then
numDataBytes = numDataBytes - 1
thisData = 0
Else
thisData = InStr(Base64CodeBase, thisChar) - 1
End if
If thisData=-1 Then
Err.Raise 2, "Base64Decode", "Bad character In Base64 string."
Exit function
End if
groupData = 64 * groupData + thisData
Next
' Convert 3-byte integer into up To 3 ch
' aracters
Dim OneChar
For CharCounter = 1 To numDataBytes
Select Case CharCounter
Case 1: OneChar = groupData \ 65536
Case 2: OneChar = (groupData And 65535) \ 256
Case 3: OneChar = (groupData And 255)
End Select
Out = Out & Chr(OneChar)
Next
Next
Base64Decode = Out
End function