9 Replies - 13513 Views - Last Post: 13 August 2012 - 12:21 PM Rate Topic: -----

#1 vbnewbeginer  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 53
  • Joined: 25-July 12

Blocks the user after 3rd incorrect password attemps in Login Form

Posted 13 August 2012 - 01:56 AM

I made a login form that with 3 incorrect password attemps, then the form will automically closed after the max attemps, but i want to create a log in form that bocks the user who logged in, using a time interval. I do not know the logic and the codes, please someone help or suggest?



Here is my code:

 If ask() = True Then
            Me.GdpccTableTableAdapter.FillByUsername(Me.GdpccDataSet.gdpccTable, Me.TextBox1.Text)
            If StatusTextBox.Text = "Pending" Then MessageBox.Show("Account Not Verified", " ", MessageBoxButtons.OK, MessageBoxIcon.Information)
            If StatusTextBox.Text = "Active" Then
                form_employee.Show()
                MessageBox.Show("Welcome " & TextBox1.Text & "!")
                TextBox1.Text = ""
                TextBox2.Text = ""
                TextBox4.Text = ""
                TextBox5.Text = ""
                Attempt = 1
                Me.Close()
            End If

        ElseIf TextBox1.Text = "" And TextBox2.Text = "" Then
            MessageBox.Show("Input Username and Password")

        ElseIf TextBox1.Text = "" Then
            MessageBox.Show("Input Username")
            TextBox2.Text = ""

        ElseIf TextBox2.Text = "" Then
            MessageBox.Show("Input Password")
            TextBox1.Text = ""

        ElseIf TextBox1.Text = "admin" And TextBox2.Text = "pass" Then

            form_admin.Show()
            MessageBox.Show("Welcome Admin!")
            Me.Close()

            TextBox1.Text = ""
            TextBox2.Text = ""
            TextBox4.Text = ""
            TextBox5.Text = ""

        ElseIf Attempt = 3 Then
            MsgBox("Maximum number of Attempts(3), Program will now Shutdown")
            TextBox1.Text = ""
            TextBox2.Text = ""
            TextBox4.Text = ""
            TextBox5.Text = ""
            Me.Close()


        ElseIf ask() = False Then
            MessageBox.Show("Invalid Username and Password! You currently have reached Attempt " & Attempt & " of 3.")
            Attempt = Attempt + 1
            TextBox1.Text = ""
            TextBox2.Text = ""
            TextBox4.Text = ""
            TextBox5.Text = ""
            TextBox1.Focus()







Is This A Good Question/Topic? 0
  • +

Replies To: Blocks the user after 3rd incorrect password attemps in Login Form

#2 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1820
  • View blog
  • Posts: 4,627
  • Joined: 14-March 10

Re: Blocks the user after 3rd incorrect password attemps in Login Form

Posted 13 August 2012 - 04:19 AM

SO what is your problem exactly? I didnt get what you are saying here:

Quote

but i want to create a log in form that bocks the user who logged in, using a time interval.

What do you mean by blocking a user who logged in? You want after a certain time to be "timed out" and logged out automatically? If so then you will a TimeStamp or timer to do your job. After logging in activate a timer an count down to 0. If zero, then logout automatically.

Also please use proper and good names for your controls, instead of textbox1,2,3... you better say something like:
txtUserName, txtpassword and so.
Was This Post Helpful? 1
  • +
  • -

#3 vbnewbeginer  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 53
  • Joined: 25-July 12

Re: Blocks the user after 3rd incorrect password attemps in Login Form

Posted 13 August 2012 - 04:56 AM

Sorry for my text, I want to create a login that block the user after he/she inputs 3 incrrect password attempts, Is it better to use a Timer? The interval is set to 180 seconds, the user can not sign up in 180 seconds.

I already changed the textbox, thanks for the suggestions


    Private Sub login_button_Buttonclicked(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles login_button.Buttonclicked

        If ask() = True Then
            Me.GdpccTableTableAdapter.FillByUsername(Me.GdpccDataSet.gdpccTable, Me.Login_user_txt.Text)
            If StatusTextBox.Text = "Pending" Then MessageBox.Show("Account Not Verified", " ", MessageBoxButtons.OK, MessageBoxIcon.Information)
            If StatusTextBox.Text = "Active" Then
                form_employee.Show()
                MessageBox.Show("Welcome " & Login_user_txt.Text & "!")
                Login_user_txt.Text = ""
                Login_pass_txt.Text = ""
                FrgtPass_user_txt.Text = ""
                FrgtPass_passwrd_txt.Text = ""
                Attempt = 1
                Me.Close()
            End If

        ElseIf Login_user_txt.Text = "" And Login_pass_txt.Text = "" Then
            MessageBox.Show("Input Username and Password")

        ElseIf Login_user_txt.Text = "" Then
            MessageBox.Show("Input Username")
            Login_pass_txt.Text = ""

        ElseIf Login_pass_txt.Text = "" Then
            MessageBox.Show("Input Password")
            Login_user_txt.Text = ""

        ElseIf Login_user_txt.Text = "admin" And Login_pass_txt.Text = "pass" Then

            form_admin.Show()
            MessageBox.Show("Welcome Admin!")
            Me.Close()

            Login_user_txt.Text = ""
            Login_pass_txt.Text = ""
            FrgtPass_user_txt.Text = ""
            FrgtPass_passwrd_txt.Text = ""

        ElseIf Attempt = 3 Then
            MsgBox("Maximum number of Attempts(3), Program will now Shutdown")
            Login_user_txt.Text = ""
            Login_pass_txt.Text = ""
            FrgtPass_user_txt.Text = ""
            FrgtPass_passwrd_txt.Text = ""
            Me.Close()


        ElseIf ask() = False Then
            MessageBox.Show("Invalid Username and Password! You currently have reached Attempt " & Attempt & " of 3.")
            Attempt = Attempt + 1
            Login_user_txt.Text = ""
            Login_pass_txt.Text = ""
            FrgtPass_user_txt.Text = ""
            FrgtPass_passwrd_txt.Text = ""
            Login_user_txt.Focus()




        End If
    End Sub



Was This Post Helpful? 0
  • +
  • -

#4 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1820
  • View blog
  • Posts: 4,627
  • Joined: 14-March 10

Re: Blocks the user after 3rd incorrect password attemps in Login Form

Posted 13 August 2012 - 05:16 AM

Ya sure, now I got it. Then you dont need to close the application, just you need to disable the login button for those minutes which you need. That means you will need a timer to do the job:
-Make the timer interval to 1sec (or min) so it ticks every second to count to seconds which you need. If the count reaches the value you need you enable again the button.

Or you can use time stamp and start to count and stop when it reaches the count which you need. (But the first idea is simple and easy).
Was This Post Helpful? 1
  • +
  • -

#5 vbnewbeginer  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 53
  • Joined: 25-July 12

Re: Blocks the user after 3rd incorrect password attemps in Login Form

Posted 13 August 2012 - 07:02 AM

Thanks sir! I will try it and show to you the results.
I have one more question, If the login form was closed, then Run it again, is the login button still disabled?
Was This Post Helpful? 0
  • +
  • -

#6 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1820
  • View blog
  • Posts: 4,627
  • Joined: 14-March 10

Re: Blocks the user after 3rd incorrect password attemps in Login Form

Posted 13 August 2012 - 07:43 AM

No it wont, that is another instance of a program which wont know what has been done by the previous example.
Unless you will have to use permanent storage like files and so.
Was This Post Helpful? 0
  • +
  • -

#7 vbnewbeginer  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 53
  • Joined: 25-July 12

Re: Blocks the user after 3rd incorrect password attemps in Login Form

Posted 13 August 2012 - 08:07 AM

Ohh i see, by the way thanks, I try using the timer, but it doesnt stop and the button is still disabled..
Heres the code:

   Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Timer1.Interval = 1
        Timer1.Start()
        login_button.Enabled = False
        Login_user_txt.Enabled = False
        Login_pass_txt.Enabled = False
        If Timer1.Interval = 180 Then
            Timer1.Stop()
            MessageBox.Show("Login Available", "Message Box", MessageBoxButtons.OK, MessageBoxIcon.Information)
            login_button.Enabled = True
            Login_user_txt.Enabled = True
            Login_pass_txt.Enabled = True


        End If

    End Sub



Oh sir sorry, my logic was wrong, because when the login button is disabled, other users can't log in too.. My problem is I want to block the "user" who attemps incorrect passwords..
Was This Post Helpful? 0
  • +
  • -

#8 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1820
  • View blog
  • Posts: 4,627
  • Joined: 14-March 10

Re: Blocks the user after 3rd incorrect password attemps in Login Form

Posted 13 August 2012 - 11:50 AM

You cant be sure if the user is the one who was trying the wrong password, but here is the idea:
Have a column in your user table, and if user has attempt three times, set the time of his last attempt, the next time he try to login check if the minutes you want has passed already and you can allow login if accepted.
I think you get the idea here,after a three time failure, save to his info the current time, then when he/she try to login again, check if the time required to wait has passed.
This means in your login form you will have to check for that column for everyone, it wont affect others because the allowed time will be always true for them. When user is first time registered, set the column to current time - the wait time so it wont affect him/her when try to login.
Was This Post Helpful? 1
  • +
  • -

#9 DarenR  Icon User is offline

  • D.I.C Lover

Reputation: 497
  • View blog
  • Posts: 3,315
  • Joined: 12-January 10

Re: Blocks the user after 3rd incorrect password attemps in Login Form

Posted 13 August 2012 - 12:15 PM

the only way that you can stop a user from accessing the page after failed attempts is to grab the IP of the user -- store it in a table and check against the table.
Was This Post Helpful? 1
  • +
  • -

#10 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1820
  • View blog
  • Posts: 4,627
  • Joined: 14-March 10

Re: Blocks the user after 3rd incorrect password attemps in Login Form

Posted 13 August 2012 - 12:21 PM

That will only work if not in proxy or not changing the computer used to access the application.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1