Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
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 17-Oct-12 5:43am
D-Bar310
Edited 17-Oct-12 6:02am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Very simple, when a user successfully logs in, just add the logic to that process which sets that field back to 0.
  Permalink  
Comments
D-Bar at 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 at 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.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  
v2
Comments
D-Bar at 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)

  Print Answers RSS
0 CPallini 540
1 Sergey Alexandrovich Kryukov 420
2 George Jonsson 328
3 Pheonyx 218
4 OriginalGriff 215
0 OriginalGriff 4,813
1 CPallini 3,890
2 Sergey Alexandrovich Kryukov 3,274
3 George Jonsson 2,552
4 Gihan Liyanage 2,186


Advertise | Privacy | Mobile
Web04 | 2.8.140905.1 | Last Updated 17 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100