如何在3次无效登录尝试后阻止用户 [英] how to block user after 3 invalid login attempts

查看:102
本文介绍了如何在3次无效登录尝试后阻止用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在3次无效尝试后阻止用户。并且我有一个包含2列usernaem和密码的表。

i want to block user after 3 invalid attempts. and i''ve a table which contains 2 columns usernaem and password.

推荐答案

您可以随时查看.Net中的成员资格服务框架,而不是自己滚动。 。



或者,

添加一个整数FailedLogin列,每次登录失败时增加,成功登录时设置为0。



添加布尔锁定列,如果失败计数超过您的触发水平,则设置为true。



还有其他方式这样做,但这可能是最简单的。
Rather than roll your own, you could always look at the membership services frameworks within .Net.

Alternatively,
Add an integer FailedLogin column, increment that each failed login, set to 0 on successful login.

Add a Boolean Locked column, if failed count exceeds your trigger level, set to true.

There are other ways of doing this, but that is probably the simplest.




在下面的代码我解释了逻辑,如何实现它。如果您需要任何说明,请告诉我。

Hi,
In below code I have explained the logic , how to implement that. If you need any clarifications do let me know.
int NoOfLoginAttempt = 0;
       private void btnLogin_Click(object sender, EventArgs e)
       {
          //Get the User name & Password from the text box
           //Connect to database and get the user details
          if(FOUND )
          {
               if(Password is matched)
               {
                   if(NoOfLoginAttempt ==3)
                   {
                       //connect to database and set the blockFlag=true;
                       //Inform the user that, your account is blocked.
                   }
                   else
                   {

                       NoOfLoginAttempt++;
                       //Show message box to usr to re-enter the password again
                   }
               }
          }
       else
        {
           //show the message box "user not exist"
       }
   }

< br $>


最好的问候

Muthuraja



Best Regards
Muthuraja


关注答案在5次登录尝试后阻止用户15分钟 [ ^ ],建议使用 SqlMembershipProvider [ ^ ]。



谢谢......
Follow the answer Block user for 15 minutes after 5 login attempts[^], which suggests to use SqlMembershipProvider[^].

Thanks...


这篇关于如何在3次无效登录尝试后阻止用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆