Click here to Skip to main content
12,952,792 members (34,452 online)
Rate this:
 
Please Sign up or sign in to vote.
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 17-Oct-12 5:43am
D-Bar318
Updated 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 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.
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 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
Top Experts
Last 24hrsThis month
OriginalGriff 6,389
CHill60 3,490
Maciej Los 3,103
Jochen Arndt 1,975
ppolymorphe 1,920


Advertise | Privacy | Mobile
Web01 | 2.8.170525.1 | Last Updated 17 Oct 2012
Copyright © CodeProject, 1999-2017
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