473,399 Members | 4,177 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Log System with 3 attempts and block the user after 3rd attempt with time interval

I have a log in form with max attempts of 3 then the program will automatically closed, but i want to find the code to block the user to log in with a time interval..Im using VB 2008(VB.net) and MS ACCESS 2010 as back end..

Here's my code:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Imports System.Data.OleDb
  3. Public Class LogForm
  4.     Dim Attempt As Integer = 1
  5.     Dim con As New OleDbConnection
  6.  
  7.     Private Sub LoginForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  8.         con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\GDPCC\gdpcc.mdb"
  9.     End Sub
  10.     Public Function ask()
  11.         Dim dt As New DataTable
  12.         Dim ds As New DataSet
  13.         ds.Tables.Add(dt)
  14.         con.Open()
  15.         Dim da As New OleDbDataAdapter("select * from gdpccTable", con)
  16.         da.Fill(dt)
  17.         For Each datarow In dt.Rows
  18.             If TextBox1.Text = datarow.item(7) And TextBox2.Text = datarow(8) Then
  19.                 con.Close()
  20.                 Return True
  21.  
  22.             End If
  23.         Next
  24.  
  25.         con.Close()
  26.         Return False
  27.  
  28.     End Function
  29.  
  30.  
  31.     Private Sub login_button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles login_button.Click
  32.         If ask() = True Then
  33.             EmpForm.Show()
  34.             Me.Hide()
  35.             MessageBox.Show("WELCOME '" & TextBox1.Text & "'")
  36.             TextBox1.Text = ""
  37.             TextBox2.Text = ""
  38.  
  39.         ElseIf TextBox1.Text = "" And TextBox2.Text = "" Then
  40.             MessageBox.Show("Input Username and Password")
  41.  
  42.         ElseIf TextBox1.Text = "" Then
  43.             MessageBox.Show("Input Username")
  44.             TextBox2.Text = ""
  45.  
  46.         ElseIf TextBox2.Text = "" Then
  47.             MessageBox.Show("Input Password")
  48.             TextBox1.Text = ""
  49.  
  50.         ElseIf TextBox1.Text = "admin" And TextBox2.Text = "pass" Then
  51.             MessageBox.Show("Welcome Admin!!!")
  52.             AdminForm.Show()
  53.             Me.Hide()
  54.  
  55.             TextBox1.Text = ""
  56.             TextBox2.Text = ""
  57.  
  58.         ElseIf Attempt = 3 Then
  59.             MsgBox("Maximum number of Attempts(3), Program will now Shutdown")
  60.             TextBox1.Text = ""
  61.             TextBox2.Text = ""
  62.             Me.Close()
  63.  
  64.  
  65.         ElseIf ask() = False Then
  66.             MessageBox.Show("Invalid Username and Password! You currently have reached Attempt" & Attempt & " of 3.")
  67.             Attempt = Attempt + 1
  68.             TextBox1.Text = ""
  69.             TextBox2.Text = ""
  70.             TextBox1.Focus()
  71.  
  72.  
  73.         End If
  74.     End Sub
  75.   End Class
  76.  
  77.  
Jul 3 '12 #1

✓ answered by zmbd

There are a few ways to accomplish this; however, the most straight forward would be to have a table that logs the user name and the last time a login failed.
From there, your login form checks that table and compares the user id attempting to login against the table to see if that name is there and if the current system time is greater than the time of the last login attempt by the amount of time you desire if the name is listed.

-z

3 8285
zmbd
5,501 Expert Mod 4TB
There are a few ways to accomplish this; however, the most straight forward would be to have a table that logs the user name and the last time a login failed.
From there, your login form checks that table and compares the user id attempting to login against the table to see if that name is there and if the current system time is greater than the time of the last login attempt by the amount of time you desire if the name is listed.

-z
Aug 13 '12 #2
Thanks Sir! It helps!
Aug 13 '12 #3
zmbd
5,501 Expert Mod 4TB
I should mentioned one thing to remember is that access isn't a totaly secure program. There are ways for the user to bypass almost anything done by the programmer.
-z
Aug 13 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Rob | last post by:
Hi, I have a question, when you use a random number generator Random() in a loop to generate say 50000 random numbers; is it any difference if you use different time interval between each loop...
4
by: Andrew Poulos | last post by:
How do I convert a length of time, measured in seconds, into a "point in time" type time interval or what's represented as: time (second,10,2) The format is: PS]] where: y: The number of...
2
by: VB User | last post by:
I need to which time interval a given time is within. What is the function I can use?
1
by: greg chu | last post by:
Hi, not sure who has done this. I want to set up a time interval that could be pass midnight. so people can enter 8AM to 8AM (pass midnight to 2nd day) 8AM to 2 AM (pass midnight to 2nd day)...
0
by: achio84 | last post by:
Hi all, I'm a newbie in .Net programming. I'm developing a web application that has a listbox containing more than 1000++ items. This listbox is dynamic as the content will change on a time...
6
by: newsteve1 | last post by:
hi, this should be simple but its stumping me, I am trying to make a slideshow that pulls random images at a random time interval (between 1 and 4 seconds). The images part works fine, and I...
1
by: mndprasad | last post by:
Hi all I need a help here..am doing an application in jsp..i got struck in a position where i have not done that before There are multiple users in my application..for each user the time...
0
by: mariasoosai | last post by:
I have to send the jobs status that are started running from the previous day 9.00 a.m to today 9 a.m from the table sysjobhistory in sql server msdb database.But in that table , date and time are...
1
by: madankarmukta | last post by:
HI, I created the process which is hook to launch just before the Desktop appears and after the login credentials are entered by the machine owner.In Xp it is giving the expected result i.e. my...
4
by: yuvang | last post by:
i have a mdb located in server and n number of users are accessing and adding data to that mdb (source table). now i want to save the mdb tables in particular time interval frequently.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.