Bonjour à tous
J ai essayé de créer un système de gestion de logins et mots de passe basé sur une base de données Access. La structure de la table: username,pasword et destination.
Login.aspx:
<%
@PageLanguage="VB" %><%
@ImportNamespace="System.Web.Security" %><%
@ImportNamespace="System.Data" %><%
@ImportNamespace="System.Data.OleDb" %><
scriptlanguage="VB"runat="server">Sub btnLogin_OnClick(Src AsObject, E As EventArgs)Dim myConnection As OleDbConnectionDim myCommand As OleDbCommandDim strUserURL AsStringDim strSQL AsStringstrSQL =
"SELECT destination FROM tblLoginInfo " _&
"WHERE username='" & Replace(txtUsername.Text, "'", "''") & "' " _&
"AND password='" & Replace(txtPassword.Text, "'", "''") & "';"myConnection =
New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " & "Data Source=" & Server.MapPath("login.mdb") & ";")'myConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; " & "Data Source=" & Server.MapPath("databases/login.mdb") & ";")myCommand =
New OleDbCommand(strSQL, myConnection)myConnection.Open()
strUserURL = myCommand.ExecuteScalar()
myConnection.Close()
'Response.Write(intUserCount)If strUserURL <> ""ThenlblInvalid.Text =
""FormsAuthentication.SetAuthCookie(txtUsername.Text,
True)Response.Redirect(strUserURL)
ElselblInvalid.Text =
"Sorry... try again..."EndIfEndSub</
script><
html><
head><
title>Connexion...</title></
head><
body><
p><
asp:Labelid="lblInvalid"runat="server"/></
p><
formid="Form1"runat="server">Username:
<asp:TextBoxid="txtUsername"runat="server"/><br/>Password:
<asp:TextBoxid="txtPassword"TextMode="password"runat="server"/><br/><br/><asp:Buttonid="btnLogin"runat="server"text="Login"OnClick="btnLogin_OnClick"/></
form>
</
body></
html>
web.config:
<
configurationxmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"><
system.web><
roleManagerenabled="true" /><
customErrorsmode="Off"/><
authenticationmode="Forms"><
formsname=".ASPXAUTH"loginUrl="login.aspx"protection="All"timeout="1"path="/"></
forms></
authentication></
system.web><
locationpath="Default.aspx"><
system.web><
authorization><
allowusers="Doru" /><
denyusers="*" /></
authorization></
system.web></
location></
configuration>
je m atendais que le système prenne en charge les autorisations déclarées ds web.config. Ce qui n est pas le cas. Un user déclaré ds la base de donées a quand même accès aux ressorces du site.
Je ne trouve pas d explications!!!