高分求关于验证登陆方法的实现方法和源码
也可以考虑添加代码,以防黑客使用不同的密码组合进行登录。例如,可以包含一个只允许两次或三次登录尝试的逻辑。如果用户在尝试特定次数后无法登录,您可能希望在数据库中设置一个标志以禁止此用户登录,直到此用户通过访问另外一个页面或拨打您的支持电话重新启用其帐户时为止。另外,还应根据需要添加相应的错误处理代码。
能不能讲一下比较详细的实现方案?我不想用那种生成图片验证码的那一种。
问题点数:100、回复次数:11Top
1 楼gxboy(Blin 小学生学.NET)回复于 2004-07-03 17:47:51 得分 5
session("logino") += 1
if session("logino") = 3 then
....................................
end ifTop
2 楼CMIC(大象)回复于 2004-07-03 17:55:41 得分 5
Asp.net中基于Forms验证的角色验证授权
http://dev.csdn.net/develop/article/18/18958.shtm
关于黑客密码组合进行登录可以,在数据库中加一个时间字段,表示允许登录时间,当用户连续输入3次不正确密码后将这个时间设置到现在时间30分钟后,让这个用户不能在30分钟内再次尝试登录。
Top
3 楼cuike519(I will be back!)回复于 2004-07-03 18:42:00 得分 5
使用随机字符的方法。再使用SSL。看看银行的系统就知道了!再通过一些时间限制,我想应该是没有问题。基于角色的验证和这个安全性应该没有多大关系!Top
4 楼kill3434(怫悰)回复于 2004-07-03 20:11:53 得分 0
关于Forms验证,我的网站大部分需要允许访客访问,也可以注册用户访问,还有管理员的后台管理,我怎么觉得好不用?怎样将注册用户和Forms身份验证结合起来?
关于SSL,能不能详细一点?能不能贴出点源码来?Top
5 楼Tomgus(小桥流水)回复于 2004-07-03 20:22:59 得分 5
使用如下web.config设置.如何使它除了Login.aspx,和SignUp.aspx(注册页面)不需要认证,其他都需要?
<authentication mode="Forms">
<forms name="YnaBooking" path="/" loginUrl="Secure\Login.aspx" protection="All">
</forms>
</authentication>
<authorization>
<deny users="?" />
</authorization>
---------------------------------------------------------------
加上
<location path="SignUp.aspx">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
Top
6 楼kill3434(怫悰)回复于 2004-07-03 20:48:16 得分 0
楼上的好像是这样Top
7 楼misvcom(零下一度)回复于 2004-07-03 20:53:19 得分 50
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace FriendsReunion.Secure
{
public class Login : FriendsBase
{
protected System.Web.UI.HtmlControls.HtmlInputText txtLogin;
protected System.Web.UI.HtmlControls.HtmlInputButton btnLogin;
protected System.Web.UI.HtmlControls.HtmlGenericControl lblMessage;
protected System.Web.UI.HtmlControls.HtmlInputText txtPwd;
protected System.Web.UI.WebControls.Label lblError;
protected System.Web.UI.WebControls.CheckBox chkPersist;
protected System.Web.UI.WebControls.Panel pnlError;
private void Page_Load(object sender, System.EventArgs e)
{
base.HeaderIconImageUrl = Request.ApplicationPath + "/Images/securekeys.gif";
base.HeaderMessage = "Login Page";
}
#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.btnLogin.ServerClick += new System.EventHandler(this.btnLogin_ServerClick);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void btnLogin_ServerClick(object sender, System.EventArgs e)
{
SqlConnection con;
string sql;
SqlCommand cmd;
string id;
con = new SqlConnection("data source=(local)\\NetSdk;initial catalog=FriendsData;user id=sa");
sql = "SELECT UserID FROM [User] WHERE Login='{0}' and Password='{1}'";
// Format the string with the values provided
sql = String.Format(sql, txtLogin.Value, txtPwd.Value);
cmd = new SqlCommand(sql, con);
con.Open();
try
{
// Retrieve the UserID
id = (string) cmd.ExecuteScalar();
}
finally
{
con.Close();
}
if (id != null)
{
// Set the user as authenticated and send him to the page originally requested.
FormsAuthentication.RedirectFromLoginPage(id, chkPersist.Checked);
}
else
{
this.pnlError.Visible = true;
this.lblError.Text = "Invalid user name or password!";
}
}
}
}
Top
8 楼misvcom(零下一度)回复于 2004-07-03 20:56:38 得分 5
还有,最好能在验证的过程中,对用户名,密码进行加密Top
9 楼zhaizl(男儿风)回复于 2004-07-03 21:20:52 得分 5
up
Top
10 楼kkun(素颜)回复于 2004-07-03 21:33:54 得分 10
暴力的时候,数据层上会出现类ddos的情况,人多地话可以在内存里做这个事情Top
11 楼kkun(素颜)回复于 2004-07-03 21:34:44 得分 10
PS:session是不能限制的,因为SessionID是可以通过修改HTTP HEADER来进行伪造的。每次请求都是一个新SESSIONTop




