Click here to Skip to main content
15,908,834 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All, I have an ASP.NET 4.0 C# site. I am tracking failed log in attempts. After 3 I lock account. I am using a database to keep track of invalid login attempts. I got it to work if user enters 3 bad attempts in a row. My problem is if they only have 2 failed attempts, I need to delete info in database before next user tries to log in, if I don't and they have just 1 failed attempt they will be locked out. I tried using if !IsPostBack on Page load, but apparently clicking on a link that brings user back to log in page is NOT a postback. Any ideas or suggestions would be greatly appreciated.

Thanks,
D
Posted
Updated 17-Oct-12 6:02am
v2

Very simple, when a user successfully logs in, just add the logic to that process which sets that field back to 0.
 
Share this answer
 
Comments
D-Bar 17-Oct-12 15:43pm    
Hi Marcus, Thanks for replying so soon. You answered my second problem before I even asked it! I just need it spelled out a little more since I am somewhat new to coding in ASP.NET 4 and C#. In my database I have a field called "IsLocked" data type int. If the value in this field is 1 will the app "magically" know that the account is supposed to be locked? I tried this.LoginUser.IsApproved = False;, but it is giving me an error.

Thanks,
D
psychic6000 17-Oct-12 23:19pm    
in side the login process(code), use a boolean variable,read the isLocked into boolean, apply an if statement eg if(myboolean==false) { Say_user_is_looked(); return; } use return or reverse process(if you have written anything to database), but do not let user login.
In your code, where user gets successful login, add code which resets the count back for the user. and every time a user successfully logins, its count must be reset, no matter how many times he failed to login.
 
Share this answer
 
v2
Comments
D-Bar 17-Oct-12 15:37pm    
Thank-you very much psychic6000. You Da man (or woman)! This solved my first problem.
Marcus Kramer has answered my second problem before I even asked it! I just need it spelled out a little more since I am somewhat new to coding in ASP.NET 4 and C#.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900