Untitled
By: a guest | Mar 20th, 2010 | Syntax:
None | Size: 2.22 KB | Hits: 41 | Expires: Never
login.aspx
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="login.aspx.cs" Inherits="PresenceLogin.login" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Presence</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>Presence</h1>
<font face="Arial" ptsize="3">Please log in.</font>
<br /><br />
<h2>User:</h2>
<asp:TextBox ID="username" runat="server"/>
<h2>Password:</h2>
<asp:TextBox ID="password" runat="server" TextMode="Password"/>
<br />
<asp:Button ID="submit" runat="server" OnClick="checkCreds" Text="Submit" />
</div>
</form>
</body>
</html>
login.aspx.cs
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace PresenceLogin
{
public partial class login : System.Web.UI.Page
{
protected Dictionary<String, String> userList = new Dictionary<String, String>();
protected String inputHash;
protected void Page_Load(object sender, EventArgs e)
{
userList.Add("jarred", "FDCCA2432652E9CD534A27E5D8A532A8");
userList.Add("ghassan", "21b09aa6c3ad1ad22d7e50dc7836dcfe");
userList.Add("kevin", "8a06b507f0b8233f8b0c993880c8fe16");
}
protected void checkCreds(Object o, EventArgs e)
{
inputHash = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(username.Text + password.Text,"MD5");
if (!userList.ContainsKey(username.Text)) { Response.Write("User not found."); }
else {
if (userList[username.Text] == inputHash) { Response.Redirect("passaccepted.htm"); }
else { Response.Write("Invalid password"); }
}
}
}
}