Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to lock password if wrong password enterd 3 times

How to lock password if wrong password enterd 3 times

Scheduled Pinned Locked Moved C#
csharphelptutorial
6 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    veereshIndia
    wrote on last edited by
    #1

    Hi All, Iam having one table in that i have 3 fields UserId Password ULock veeresh xyz 1 1-Unlock 0-Lock If some budy enters wrong password 3 times that userid should be locked. i.e ULock value should be 0.I need c# code for this.Please help me on this.

    i want to join this group

    B A A B K 5 Replies Last reply
    0
    • V veereshIndia

      Hi All, Iam having one table in that i have 3 fields UserId Password ULock veeresh xyz 1 1-Unlock 0-Lock If some budy enters wrong password 3 times that userid should be locked. i.e ULock value should be 0.I need c# code for this.Please help me on this.

      i want to join this group

      B Offline
      B Offline
      Binod K
      wrote on last edited by
      #2

      Hi Veeru, I guess you want to lock the table for that particular user, not for others, Correct........... Here is your Answer: When user enter password, take a count of his attempts. This you will have to do on the Ok button. Whenever he clicks on OK button after supplying the password, the value of Count will increase by 1. Every time you check the value of count.If it is 3 then fire a Update SQL Query to change Unlock value from 1 to 0. Lets Try this.........:laugh: Binod

      1 Reply Last reply
      0
      • V veereshIndia

        Hi All, Iam having one table in that i have 3 fields UserId Password ULock veeresh xyz 1 1-Unlock 0-Lock If some budy enters wrong password 3 times that userid should be locked. i.e ULock value should be 0.I need c# code for this.Please help me on this.

        i want to join this group

        A Offline
        A Offline
        Abhijit Jana
        wrote on last edited by
        #3

        you can use a simple counter for that :)

        Best Regards ----------------- Abhijit Jana View My CodeProject Articles "Success is Journey it's not a destination"

        1 Reply Last reply
        0
        • V veereshIndia

          Hi All, Iam having one table in that i have 3 fields UserId Password ULock veeresh xyz 1 1-Unlock 0-Lock If some budy enters wrong password 3 times that userid should be locked. i.e ULock value should be 0.I need c# code for this.Please help me on this.

          i want to join this group

          A Offline
          A Offline
          Adeel Chaudhry
          wrote on last edited by
          #4

          Hi, As suggested by other other fellows, have a counter in authentication procedure/routine, count for invalid tries, and if the count reaches 3, change the ULock to 0. You can even add a column for the total number of times the account ws locked in the same column. Just an idea! :) Regards, Adeel

          Do rate the reply, if it helps or even if it doesnot, because it helps the members to know, what solved the issue. Thanks.

          1 Reply Last reply
          0
          • V veereshIndia

            Hi All, Iam having one table in that i have 3 fields UserId Password ULock veeresh xyz 1 1-Unlock 0-Lock If some budy enters wrong password 3 times that userid should be locked. i.e ULock value should be 0.I need c# code for this.Please help me on this.

            i want to join this group

            B Offline
            B Offline
            Basavarajayya
            wrote on last edited by
            #5

            I wil just tell u the Procedure to be done. 1.Initailly the default value of ULock will be 1. 2. Declare a variable WrongPwdCount=0; 3.Check the status of the ULock if ULock==0 Display the Message as " Your account is locked" else WrongPwdCount++; 4. if WrongPwdCount==3 Change the ULock=0 else Do a successful login Let me know if this works.... Otherwise Let me send a code for the same Regards Basavarajayya

            1 Reply Last reply
            0
            • V veereshIndia

              Hi All, Iam having one table in that i have 3 fields UserId Password ULock veeresh xyz 1 1-Unlock 0-Lock If some budy enters wrong password 3 times that userid should be locked. i.e ULock value should be 0.I need c# code for this.Please help me on this.

              i want to join this group

              K Offline
              K Offline
              KennyPatel
              wrote on last edited by
              #6

              Try This. SqlConnection con = new SqlConnection("Data Source=;Database=;User Id=;Password="); SqlCommand cmd; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { hfCounter.Value = "1"; } } protected void btLogin_Click(object sender, EventArgs e) { try { con.Open(); string xSql="select * from where userid='" + txtUser.Text + "' and pswd='" + txtPswd.Text + "'"; cmd = new SqlCommand(xSql,con); SqlDataReader rd = cmd.ExecuteReader(); int x = Convert.ToInt32(hfCounter.Value); if (x == 3) { lblMsg.Text = "User Locked....!"; // write your process here. to change the Lock Status from 0 to 1 OR 1 to 0 etc... } else { if (rd.HasRows != true) { x++; hfCounter.Value = x.ToString(); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { con.Close(); } } I hope Helps you out. I used Two TextBox, Label, Button, HiddenField :rolleyes:

              " Good Things Goes with Good People "

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups