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
| protected void loginAdmin_Authenticate(object sender, AuthenticateEventArgs e)
{
if (Authentifier(loginAdmin.UserName, loginAdmin.Password))
{
FormsAuthentication.RedirectFromLoginPage(loginAdmin.UserName, false);
}
}
private bool Authentifier(string strUtilisateur, string strMotDePasse)
{
bool bOk = false;
// Cryptage du mot de passe
strMotDePasse = FormsAuthentication.HashPasswordForStoringInConfigFile(strMotDePasse, "MD5");
WebAMI.Utils.sql.ConnectionBase();
// Définition de la requête à exécuter
SqlCommand oCommand = new SqlCommand("SELECT * FROM Utilisateur WHERE login='" + strUtilisateur + "'", WebAMI.Utils.sql._connection);
try
{
SqlDataReader drUtilisateur = oCommand.ExecuteReader();
// Parcours de la liste des utilisateurs
while (drUtilisateur.Read())
{
if (drUtilisateur["password"].ToString().ToUpper() == strMotDePasse.ToUpper())
{
bOk = true; break;
}
}
}
catch
{
bOk = false;
}
WebAMI.Utils.sql._connection.Close();
return bOk;
} |
Partager