- ' ------ Dans web.config -----------
-
- <authentication mode="Forms">
- <forms name=".ASPXUSERDEMO" loginUrl="login.aspx" protection="All" timeout="60" />
- </authentication>
- ' Oblige le passage par la page login.aspx pour s'identifier lors de l'arrivée sur toutes les pages du projet
-
- <authorization>
- <deny users="?" />
- <allow users="*" />
- </authorization>
- ' Autorisation a tous les utilisateurs identifiés, interdiction au non connus
-
- ' -------- Page Login.aspx ------------
-
- <form method="post" runat="server">
- <table cellSpacing="0" cellPadding="2" align="center" border="0">
- <TR><TD>Login :</TD>
- <TD><asp:textbox id="login" runat="server"></asp:textbox></TD>
- </TR>
- <TR><TD><DIV align="center">Mot de Passe :</DIV></TD>
- <TD><asp:textbox id="pass" runat="server" TextMode="Password"></asp:textbox></TD>
- </TR>
- </table><br><br>
- <asp:button id="Button1" runat="server" Text="Envoyer"></asp:button>
- <P><P><P><asp:label id="Label1" runat="server"></asp:label></P>
- </FORM>
-
- ' --------Page Login.aspx.vb ---------------
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- ' Vérification de l'authentification
- Dim ODBCConnSite As String = "films"
- Dim TmpReaderType As OdbcDataReader
- Dim SQL As String = "Select * FROM password WHERE password.login='" & login.Text & "' AND password.pass='" & pass.Text & "'"
-
- TmpReaderType = MyODBCReader(SQL, ODBCConnSite)
- If TmpReaderType.Read Then
- FormsAuthentication.RedirectFromLoginPage(login.Text, False)
- Else
- Label1.Text = "Les éléments fournis ne permettent pas de vous authentifier."
- End If
- End Sub
-
- ' Cet exemple s'appuie sur une requette lancée sur une table et dont le résultat est un Datareader, ainsi si on peut lire ce reader (TmpReaderType.Read) rendra TRUE et validera l'authetification. A l'inverse elle restera sur cette même page et affichera le texte dans le label.
-
' ------ Dans web.config -----------
<authentication mode="Forms">
<forms name=".ASPXUSERDEMO" loginUrl="login.aspx" protection="All" timeout="60" />
</authentication>
' Oblige le passage par la page login.aspx pour s'identifier lors de l'arrivée sur toutes les pages du projet
<authorization>
<deny users="?" />
<allow users="*" />
</authorization>
' Autorisation a tous les utilisateurs identifiés, interdiction au non connus
' -------- Page Login.aspx ------------
<form method="post" runat="server">
<table cellSpacing="0" cellPadding="2" align="center" border="0">
<TR><TD>Login :</TD>
<TD><asp:textbox id="login" runat="server"></asp:textbox></TD>
</TR>
<TR><TD><DIV align="center">Mot de Passe :</DIV></TD>
<TD><asp:textbox id="pass" runat="server" TextMode="Password"></asp:textbox></TD>
</TR>
</table><br><br>
<asp:button id="Button1" runat="server" Text="Envoyer"></asp:button>
<P><P><P><asp:label id="Label1" runat="server"></asp:label></P>
</FORM>
' --------Page Login.aspx.vb ---------------
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' Vérification de l'authentification
Dim ODBCConnSite As String = "films"
Dim TmpReaderType As OdbcDataReader
Dim SQL As String = "Select * FROM password WHERE password.login='" & login.Text & "' AND password.pass='" & pass.Text & "'"
TmpReaderType = MyODBCReader(SQL, ODBCConnSite)
If TmpReaderType.Read Then
FormsAuthentication.RedirectFromLoginPage(login.Text, False)
Else
Label1.Text = "Les éléments fournis ne permettent pas de vous authentifier."
End If
End Sub
' Cet exemple s'appuie sur une requette lancée sur une table et dont le résultat est un Datareader, ainsi si on peut lire ce reader (TmpReaderType.Read) rendra TRUE et validera l'authetification. A l'inverse elle restera sur cette même page et affichera le texte dans le label.