Varför fungerar inte detta script?
inloggnins rutan kommer upp men lösenordet stämmer inet
<%
'Av Gunnar Liljas, 2001 - gunnar@leon.se
'Ovanstående rad ska vara kvar, om du använder skriptet
'Funktionen CheckUser byts ut mot godtycklig användarkoll, och självklart kan man kolla något annat än Session("UserID")
DoAuth
'Här fortsätter sidan, efter att man blivit godkänd
Sub DoAuth
if isempty(Session("UserID")) then
strAuth=request.servervariables("HTTP_AUTHORIZATION")
if len(strAuth)>7 then
if lcase(left(strAuth,5))="basic" then
strAuth=mid(strAuth,7)
strAuth=Base64Decode(strAuth)
arrLogin=split(strAuth,":")
strUser=arrLogin(0)
strPass=arrLogin(1)
if CheckUser(strUser,strPass) then
exit sub
end if
end if
end if
NoAuth
end if
End Sub
Function CheckUser(username,password)
if username="admin" and password="admin" then
Session("UserID")=1
CheckUser=true
end if
End Function
Sub NoAuth
Response.Status = "401 Unauthorized"
Response.AddHeader "WWW-Authenticate","BASIC Realm=Min skyddade zon"
Response.Write "<B>Fy skäms!</B>"
Response.End
End Sub
Function Base64Decode(inString)
dim strOutput,intPos,intCharPos,intBytes,intTmpPos,intTmp,strChar
CONST Base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
if (Len(inString) mod 4)<>0 then exit function
for intPos=1 to Len(inString) step 4
intBytes=3
intTmp=0
for intCharPos=0 to 3
if mid(inString, intPos + intCharPos, 1) = "=" then
intBytes=intBytes-1
intTmpPos=0
else
intTmpPos=InStr(Base64Chars, Mid(inString, intPos + intCharPos, 1)) - 1
if intTmpPos=-1 then exit function
end if
intTmp=64*intTmp+intTmpPos
next
for intCharPos=1 to intBytes
select case intCharPos
case 1:
strOutput=strOutput & chr(intTmp \ 65536)
case 2:
strOutput=strOutput & chr((intTmp and 65535) \ 256)
case 3:
strOutput=strOutput & chr(intTmp and 255)
end select
next
next
Base64Decode = strOutput
End Function
%>