Bonjour,
Voila. J'ai essayé de suivre le tutoriel vu dans http://dotnet.developpez.com/tutorie...hentification/ pour créer une authentification de mon application mais en version Oracle. Seulement ca marche pas. il n'y pas de message d'erreur mais la valeur du booléen Authentifier retourne toujours false je crois. Qui sait ou il y a l'erreur et qui est bien gentil de m'aider s'il vous plait?
voici mon code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106 using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Web.Security; using System.Data.SqlClient; using Oracle.DataAccess.Client; namespace Rindra { /// <summary> /// Summary description for Authentification. /// </summary> public class Authentification : System.Web.UI.Page { protected System.Web.UI.WebControls.Button BtOk; protected System.Web.UI.WebControls.TextBox txtUser; protected System.Web.UI.WebControls.Label lbMessage; protected System.Web.UI.WebControls.TextBox txtMdp; protected System.Web.UI.WebControls.DropDownList selectEspace; protected System.Web.UI.WebControls.Button BtAnnuler; private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here } #region Web Form Designer generated code override protected void OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); } /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.BtOk.Click += new System.EventHandler(this.BtOk_Click); this.Load += new System.EventHandler(this.Page_Load); } #endregion private void BtOk_Click(object sender, System.EventArgs e) { if (Authentifier(txtUser.Text,txtMdp.Text)) { FormsAuthentication.RedirectFromLoginPage(txtUser.Text,false ); } else { lbMessage.Text ="erreur"; } } //authentification private bool Authentifier(string strUtilisateur, string strMotDePasse) { bool bOk=false ; // Cryptage du mot de passe strMotDePasse = FormsAuthentication.HashPasswordForStoringInConfigFile(strMotDePasse,"MD5"); // Création d'une connexion SGBD OracleConnection OConnexion=new OracleConnection(); OConnexion.ConnectionString="Data Source=216;User ID=gip;Password=gippig"; // Définition de la requête à exécuter OracleCommand cmd = new OracleCommand("SELECT * FROM GIP_UTILISATEUR WHERE UTIL_NOM='" + strUtilisateur+ "'"); try { // Ouverture de la connexion et exécution de la requête OConnexion.Open(); OracleDataReader drUtilisateur = cmd.ExecuteReader(); // Parcours de la liste des utilisateurs while (drUtilisateur.Read()) { if (drUtilisateur["UTIL_PASSWORD"].ToString() == strMotDePasse) { bOk = true; break ; } } } catch { bOk = false; } OConnexion.Close(); return bOk; } } }
Partager