Visualizzazione dei risultati da 1 a 7 su 7
  1. #1
    Utente di HTML.it
    Registrato dal
    Feb 2011
    Messaggi
    13

    Problema autenticazione !!!

    Salve a tutti !

    Ho un problema con delle pagine asp alle quali ho inserito la restrizione d'accesso .
    Premetto che ho usato quella standard fornita con dreamweaver cs3 sia come autenticazione che come restrizione.

    Il problema e' il seguente:

    In locale funziona tutto a dovere ovvero mi autentico e' visualizzo le pagine protette, se non mi loggo non le vedo e vengo rimandato alla pagina d'errore stabilita.

    In remoto su un server web se non mi loggo le pagine giustamente non le vedo e se mi loggo appena loggato la prima pagina alla quale accedo si vede ma se accedo ad un'altra pagina non mi fa entrare e mi rimanda alla pagina che ho impostato come errore di login, la cosa strana e' che se insisto due o tre volte per accedere alla pagina riesco ad entrare, questo solo se sono loggato.

    Non riesco a capire il motivo credo sia qualcosa lato server, avete qualche idea?

    In locale uso iis di windows vista.

  2. #2
    pubblica il codice di riconoscimento login di una pagina

  3. #3
    Utente di HTML.it
    Registrato dal
    Feb 2011
    Messaggi
    13
    codice:
    <%
    ' *** Logout the current user.
    MM_Logout = CStr(Request.ServerVariables("URL")) & "?MM_Logoutnow=1"
    If (CStr(Request("MM_Logoutnow")) = "1") Then
      Session.Contents.Remove("MM_Username")
      Session.Contents.Remove("MM_UserAuthorization")
      MM_logoutRedirectPage = "index3.asp"
      ' redirect with URL parameters (remove the "MM_Logoutnow" query param).
      if (MM_logoutRedirectPage = "") Then MM_logoutRedirectPage = CStr(Request.ServerVariables("URL"))
      If (InStr(1, UC_redirectPage, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
        MM_newQS = "?"
        For Each Item In Request.QueryString
          If (Item <> "MM_Logoutnow") Then
            If (Len(MM_newQS) > 1) Then MM_newQS = MM_newQS & "&"
            MM_newQS = MM_newQS & Item & "=" & Server.URLencode(Request.QueryString(Item))
          End If
        Next
        if (Len(MM_newQS) > 1) Then MM_logoutRedirectPage = MM_logoutRedirectPage & MM_newQS
      End If
      Response.Redirect(MM_logoutRedirectPage)
    End If
    %>
    
    
    
    <%
    ' *** Restrict Access To Page: Grant or deny access to this page
    MM_authorizedUsers=""
    MM_authFailedURL="amministrazione.asp"
    MM_grantAccess=false
    If Session("MM_Username") <> "" Then
      If (true Or CStr(Session("MM_UserAuthorization"))="") Or _
             (InStr(1,MM_authorizedUsers,Session("MM_UserAuthorization"))>=1) Then
        MM_grantAccess = true
      End If
    End If
    If Not MM_grantAccess Then
      MM_qsChar = "?"
      If (InStr(1,MM_authFailedURL,"?") >= 1) Then MM_qsChar = "&"
      MM_referrer = Request.ServerVariables("URL")
      if (Len(Request.QueryString()) > 0) Then MM_referrer = MM_referrer & "?" & Request.QueryString()
      MM_authFailedURL = MM_authFailedURL & MM_qsChar & "accessdenied=" & Server.URLEncode(MM_referrer)
      Response.Redirect(MM_authFailedURL)
    End If
    %>
    <%
    Dim MM_editAction
    MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
    If (Request.QueryString <> "") Then
      MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
    End If
    
    ' boolean to abort record edit
    Dim MM_abortEdit
    MM_abortEdit = false
    %>
    
    
    
    <%
    If Not MM_abortEdit Then
    ' *** Validate request to log in to this site.
    MM_LoginAction = Request.ServerVariables("URL")
    If Request.QueryString <> "" Then MM_LoginAction = MM_LoginAction + "?" + Server.HTMLEncode(Request.QueryString)
    MM_valUsername = CStr(Request.Form("user"))
    If MM_valUsername <> "" Then
      Dim MM_fldUserAuthorization
      Dim MM_redirectLoginSuccess
      Dim MM_redirectLoginFailed
      Dim MM_loginSQL
      Dim MM_rsUser
      Dim MM_rsUser_cmd
      
      MM_fldUserAuthorization = ""
      MM_redirectLoginSuccess = "amministrazione.asp"
      MM_redirectLoginFailed = "admerror.asp"
    
      MM_loginSQL = "SELECT [user], password"
      If MM_fldUserAuthorization <> "" Then MM_loginSQL = MM_loginSQL & "," & MM_fldUserAuthorization
      MM_loginSQL = MM_loginSQL & " FROM [user] WHERE [user] = ? AND password = ?"
      Set MM_rsUser_cmd = Server.CreateObject ("ADODB.Command")
      MM_rsUser_cmd.ActiveConnection = MM_db_STRING
      MM_rsUser_cmd.CommandText = MM_loginSQL
      MM_rsUser_cmd.Parameters.Append MM_rsUser_cmd.CreateParameter("param1", 200, 1, 100, MM_valUsername) ' adVarChar
      MM_rsUser_cmd.Parameters.Append MM_rsUser_cmd.CreateParameter("param2", 200, 1, 20, Request.Form("psw")) ' adVarChar
      MM_rsUser_cmd.Prepared = true
      Set MM_rsUser = MM_rsUser_cmd.Execute
    
      If Not MM_rsUser.EOF Or Not MM_rsUser.BOF Then 
        ' username and password match - this is a valid user
        Session("MM_Username") = MM_valUsername
        If (MM_fldUserAuthorization <> "") Then
          Session("MM_UserAuthorization") = CStr(MM_rsUser.Fields.Item(MM_fldUserAuthorization).Value)
        Else
          Session("MM_UserAuthorization") = ""
        End If
        if CStr(Request.QueryString("accessdenied")) <> "" And false Then
          MM_redirectLoginSuccess = Request.QueryString("accessdenied")
        End If
        MM_rsUser.Close
        Response.Redirect(MM_redirectLoginSuccess)
      End If
      MM_rsUser.Close
      Response.Redirect(MM_redirectLoginFailed)
    End If
    End If
    %>

  4. #4
    Utente di HTML.it
    Registrato dal
    Feb 2011
    Messaggi
    13
    Nessuno ha qualche idea ???

    Pensavo qualcosa del tipo come si vede su qualche sito di mettere una selezione con rimani collegato, qualcuno sa come funzione ovvero che cosa fa ?

  5. #5
    Moderatore di Annunci siti web, Offro lavoro/collaborazione, Cerco lavoro L'avatar di cavicchiandrea
    Registrato dal
    Aug 2001
    Messaggi
    26,133
    Il problema potrebbe essere legato alle session o ai cookie o alle loro impostazioni non conosco dreamweaver cosi bene da capire se l'errore è sul server o nello script, prova "stravolgere" il tutto utilizzando uno script diverso di login più snello che puoi trovare qui in oltre ci trovi delle guide che possono aiutarti.
    Cavicchi Andrea
    Problemi con javascript, jquery, ajax clicca qui

  6. #6
    Originariamente inviato da cinarone
    codice:
    <%
    ' *** Logout the current user.
    MM_Logout = CStr(Request.ServerVariables("URL")) & "?MM_Logoutnow=1"
    If (CStr(Request("MM_Logoutnow")) = "1") Then
      Session.Contents.Remove("MM_Username")
      Session.Contents.Remove("MM_UserAuthorization")
      MM_logoutRedirectPage = "index3.asp"
      ' redirect with URL parameters (remove the "MM_Logoutnow" query param).
      if (MM_logoutRedirectPage = "") Then MM_logoutRedirectPage = CStr(Request.ServerVariables("URL"))
      If (InStr(1, UC_redirectPage, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
        MM_newQS = "?"
        For Each Item In Request.QueryString
          If (Item <> "MM_Logoutnow") Then
            If (Len(MM_newQS) > 1) Then MM_newQS = MM_newQS & "&"
            MM_newQS = MM_newQS & Item & "=" & Server.URLencode(Request.QueryString(Item))
          End If
        Next
        if (Len(MM_newQS) > 1) Then MM_logoutRedirectPage = MM_logoutRedirectPage & MM_newQS
      End If
      Response.Redirect(MM_logoutRedirectPage)
    End If
    %>
    
    
    
    <%
    ' *** Restrict Access To Page: Grant or deny access to this page
    MM_authorizedUsers=""
    MM_authFailedURL="amministrazione.asp"
    MM_grantAccess=false
    If Session("MM_Username") <> "" Then
      If (true Or CStr(Session("MM_UserAuthorization"))="") Or _
             (InStr(1,MM_authorizedUsers,Session("MM_UserAuthorization"))>=1) Then
        MM_grantAccess = true
      End If
    End If
    If Not MM_grantAccess Then
      MM_qsChar = "?"
      If (InStr(1,MM_authFailedURL,"?") >= 1) Then MM_qsChar = "&"
      MM_referrer = Request.ServerVariables("URL")
      if (Len(Request.QueryString()) > 0) Then MM_referrer = MM_referrer & "?" & Request.QueryString()
      MM_authFailedURL = MM_authFailedURL & MM_qsChar & "accessdenied=" & Server.URLEncode(MM_referrer)
      Response.Redirect(MM_authFailedURL)
    End If
    %>
    <%
    Dim MM_editAction
    MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
    If (Request.QueryString <> "") Then
      MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString)
    End If
    
    ' boolean to abort record edit
    Dim MM_abortEdit
    MM_abortEdit = false
    %>
    
    
    
    <%
    If Not MM_abortEdit Then
    ' *** Validate request to log in to this site.
    MM_LoginAction = Request.ServerVariables("URL")
    If Request.QueryString <> "" Then MM_LoginAction = MM_LoginAction + "?" + Server.HTMLEncode(Request.QueryString)
    MM_valUsername = CStr(Request.Form("user"))
    If MM_valUsername <> "" Then
      Dim MM_fldUserAuthorization
      Dim MM_redirectLoginSuccess
      Dim MM_redirectLoginFailed
      Dim MM_loginSQL
      Dim MM_rsUser
      Dim MM_rsUser_cmd
      
      MM_fldUserAuthorization = ""
      MM_redirectLoginSuccess = "amministrazione.asp"
      MM_redirectLoginFailed = "admerror.asp"
    
      MM_loginSQL = "SELECT [user], password"
      If MM_fldUserAuthorization <> "" Then MM_loginSQL = MM_loginSQL & "," & MM_fldUserAuthorization
      MM_loginSQL = MM_loginSQL & " FROM [user] WHERE [user] = ? AND password = ?"
      Set MM_rsUser_cmd = Server.CreateObject ("ADODB.Command")
      MM_rsUser_cmd.ActiveConnection = MM_db_STRING
      MM_rsUser_cmd.CommandText = MM_loginSQL
      MM_rsUser_cmd.Parameters.Append MM_rsUser_cmd.CreateParameter("param1", 200, 1, 100, MM_valUsername) ' adVarChar
      MM_rsUser_cmd.Parameters.Append MM_rsUser_cmd.CreateParameter("param2", 200, 1, 20, Request.Form("psw")) ' adVarChar
      MM_rsUser_cmd.Prepared = true
      Set MM_rsUser = MM_rsUser_cmd.Execute
    
      If Not MM_rsUser.EOF Or Not MM_rsUser.BOF Then 
        ' username and password match - this is a valid user
        Session("MM_Username") = MM_valUsername
        If (MM_fldUserAuthorization <> "") Then
          Session("MM_UserAuthorization") = CStr(MM_rsUser.Fields.Item(MM_fldUserAuthorization).Value)
        Else
          Session("MM_UserAuthorization") = ""
        End If
        if CStr(Request.QueryString("accessdenied")) <> "" And false Then
          MM_redirectLoginSuccess = Request.QueryString("accessdenied")
        End If
        MM_rsUser.Close
        Response.Redirect(MM_redirectLoginSuccess)
      End If
      MM_rsUser.Close
      Response.Redirect(MM_redirectLoginFailed)
    End If
    End If
    %>

    O.o macromedia crea tutta sta roba per un'autenticazione???

    questo è quello che uso io per un gestionale online, tieni presente che non c'è user name e la password è fissa, ma basterebbe recuperare user name e password e confrontarli con quelli salvati nel db
    ^_^

    codice:
    login=request.cookies("gest_usato")("pw")
    if login="........" then
     session("login")=1
    end if
    if session("login")<>1 then
     response.redirect("login.html")
    end if
    e poi controlli che session("login") sia uguale ad 1
    (io ad esempio questo codice l'ho messo solo nella pagina del menù che è presente in tutte le pagine, così in qualunque pagina se non si è loggati si viene rimandati alla richiesta password)

  7. #7
    Utente di HTML.it
    Registrato dal
    Feb 2011
    Messaggi
    13
    Allora, intanto Grazie per l'attenzione, ho provato ad utilizzare un altro codice quello consigliatomi da cavicchiandrea e stesso problema, funziona ma non tiene in memoria la "session" e passando da una pagina all'altra mi richede di effettuare l'accesso.
    A questo punto mi sa che e' il server web che ha qualcosa che al cambio pagina non tiene in memoria i dati .

    come ne esco fuori sapete dirmi cosa chiedere all'amministratore per fargli fare un controllo ?

    Questo e' il sistema che ho usato per la seconda prova :
    http://asp.html.it/articoli/leggi/67...l-nostro-sito/

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.