leon84
16-07-2003, 12:51
Allora innanzitutto vi spiego : Sono riuscito ad integrare ASPNUKE e lo SNITZFORUM . Oggi volevo aggiornare la versione dello snitz da poco rilasciata veramente molto bella e funzionale . Per l'integrazione tra i due progetti ho fatto in modo che quando un utente si registra su aspnuke gli stessi nome utente e password vengono ricopiati nel database dello snitz . Fin qui tutto bene . Mi sono però accorto che l'ultima versione dello snitz codifica le password . Cioè se io mi registro con password pippo nel database non viene riportato pippo ma una sequenza particolare di caratteri . Quando effettuo il login un opportuno algoritmo mi converte la mia password nei famosi caratteri di cui prima parlavo e se questi coincidono con quelli effettivamente presenti nel database allora sono loggato altrimenti no . Ora il punto sarebbe quello di trovare questa procedura che codifica la password e richiamarla in aspnuke prima di memorizzare la password nel database del forum . Considerando però che già ci sono diversi utenti iscritti mi converrebee fare in altro modo . Avevo infatti pensato di modificare la procedura di login del forum in modo da accettare la password immessa dall'utente così com'è senza codificarla . Ora vi posto un pò di codice :
File login.asp
if RequestMethod = "POST" Then
strEncodedPassword = sha256("" & fPassword)
select case chkUser(fName, fPassword, 1)
case 1, 2, 3, 4
Call DoCookies(Request.Form("SavePassword"))
strLoginStatus = 1
AUHandleLoging()
case else
strLoginStatus = 0
end select
if strLoginStatus = 1 then
Response.Write " <p align=""center""><font face=""" & strDefaultFontFace & """ size=""" & strHeaderFontSize & """>Sei stato riconosciuto con successo!</font></p>" & vbNewLine
Response.Write " <p align=""center""><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """><a href="""
if strTarget = "" then
Response.Write "default.asp"
else
Response.Write strTarget
end if
Response.Write """>Clicca qui per Continuare</a></font></p>" & vbNewLine
Response.Write " <meta http-equiv=""Refresh"" content=""2; URL="
if strTarget = "" then
Response.Write "default.asp"
else
Response.Write strTarget
end if
Response.Write """>" & vbNewline & _
" <br />" & vbNewLine
WriteFooter
Response.End
end if
end if
File inc_func_common.asp
function chkUser(fName, fPassword, fAuthor)
dim rsCheck
dim strSql
'## Forum_SQL
strSql = "SELECT MEMBER_ID, M_LEVEL, M_NAME, M_PASSWORD "
strSql = strSql & " FROM " & strMemberTablePrefix & "MEMBERS "
strSql = strSql & " WHERE " & strDBNTSQLName & " = '" & ChkString(fName, "SQLString") & "' "
if strAuthType="db" then
strSql = strSql & " AND M_PASSWORD = '" & ChkString(fPassword, "SQLString") &"'"
End If
strSql = strSql & " AND M_STATUS = " & 1
Set rsCheck = my_Conn.Execute(strSql)
if rsCheck.BOF or rsCheck.EOF or not(ChkQuoteOk(fName)) or not(ChkQuoteOk(fPassword)) then
MemberID = -1
chkUser = 0 '## Invalid Password
if strDBNTUserName <> "" and chkCookie = 1 then
Call ClearCookies()
strDBNTUserName = ""
end if
else
MemberID = rsCheck("MEMBER_ID")
if (rsCheck("MEMBER_ID") & "" = fAuthor & "") and (cLng(rsCheck("M_LEVEL")) <> 3) then
chkUser = 1 '## Author
else
select case cLng(rsCheck("M_LEVEL"))
case 1
chkUser = 2 '## Normal User
case 2
chkUser = 3 '## Moderator
case 3
chkUser = 4 '## Admin
case else
chkUser = cLng(rsCheck("M_LEVEL"))
end select
end if
end if
rsCheck.close
set rsCheck = nothing
end function
Da quello che son riuscito a capire , quando effettuo il login la password viene inviata alla funzione sha256 che la codifica . In seguito viene richiamata la funzione chkUser per verificare la correttezza dei dati ed è qui che la password codificata (strEncodedPassrod) viene confrontata con quella presente nel database . A questo punto ho pensato di assegnare alla variabile strEncodedPassword direttamente il valore di Request.form("Password") ed inviare questo ultimo alla funzione chkUser . Ma udite udite neppure riesco ad accedere al forum .Per favore mi aiutate ? Sto perdendo la testa . Grazie
File login.asp
if RequestMethod = "POST" Then
strEncodedPassword = sha256("" & fPassword)
select case chkUser(fName, fPassword, 1)
case 1, 2, 3, 4
Call DoCookies(Request.Form("SavePassword"))
strLoginStatus = 1
AUHandleLoging()
case else
strLoginStatus = 0
end select
if strLoginStatus = 1 then
Response.Write " <p align=""center""><font face=""" & strDefaultFontFace & """ size=""" & strHeaderFontSize & """>Sei stato riconosciuto con successo!</font></p>" & vbNewLine
Response.Write " <p align=""center""><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """><a href="""
if strTarget = "" then
Response.Write "default.asp"
else
Response.Write strTarget
end if
Response.Write """>Clicca qui per Continuare</a></font></p>" & vbNewLine
Response.Write " <meta http-equiv=""Refresh"" content=""2; URL="
if strTarget = "" then
Response.Write "default.asp"
else
Response.Write strTarget
end if
Response.Write """>" & vbNewline & _
" <br />" & vbNewLine
WriteFooter
Response.End
end if
end if
File inc_func_common.asp
function chkUser(fName, fPassword, fAuthor)
dim rsCheck
dim strSql
'## Forum_SQL
strSql = "SELECT MEMBER_ID, M_LEVEL, M_NAME, M_PASSWORD "
strSql = strSql & " FROM " & strMemberTablePrefix & "MEMBERS "
strSql = strSql & " WHERE " & strDBNTSQLName & " = '" & ChkString(fName, "SQLString") & "' "
if strAuthType="db" then
strSql = strSql & " AND M_PASSWORD = '" & ChkString(fPassword, "SQLString") &"'"
End If
strSql = strSql & " AND M_STATUS = " & 1
Set rsCheck = my_Conn.Execute(strSql)
if rsCheck.BOF or rsCheck.EOF or not(ChkQuoteOk(fName)) or not(ChkQuoteOk(fPassword)) then
MemberID = -1
chkUser = 0 '## Invalid Password
if strDBNTUserName <> "" and chkCookie = 1 then
Call ClearCookies()
strDBNTUserName = ""
end if
else
MemberID = rsCheck("MEMBER_ID")
if (rsCheck("MEMBER_ID") & "" = fAuthor & "") and (cLng(rsCheck("M_LEVEL")) <> 3) then
chkUser = 1 '## Author
else
select case cLng(rsCheck("M_LEVEL"))
case 1
chkUser = 2 '## Normal User
case 2
chkUser = 3 '## Moderator
case 3
chkUser = 4 '## Admin
case else
chkUser = cLng(rsCheck("M_LEVEL"))
end select
end if
end if
rsCheck.close
set rsCheck = nothing
end function
Da quello che son riuscito a capire , quando effettuo il login la password viene inviata alla funzione sha256 che la codifica . In seguito viene richiamata la funzione chkUser per verificare la correttezza dei dati ed è qui che la password codificata (strEncodedPassrod) viene confrontata con quella presente nel database . A questo punto ho pensato di assegnare alla variabile strEncodedPassword direttamente il valore di Request.form("Password") ed inviare questo ultimo alla funzione chkUser . Ma udite udite neppure riesco ad accedere al forum .Per favore mi aiutate ? Sto perdendo la testa . Grazie