I set up an Admin login by creating a user name and password area which gives the admin access to forms that a typical user will not see .
lets say 4 persons are using this application , i want to make it that only 3 of the 4 persons can login as Admin.
How do I do this ?
this is how i created my login function .
in the settings area of my application i created two names DBUsername
and DBPassword
and set their scope to User
PasswordField
and NameField
are the text boxes
this is a photo of the login area and the code behind it . The function works perfectly.
do not pay attention to the User Login
button
Public Class login
Private Property username As String = ""
Private Property password As String = ""
Dim Setting As New My.MySettings
Private Sub AdminLoginButton_Click(sender As Object, e As EventArgs) Handles AdminLoginButton.Click
If NameField.Text = "" And PasswordField.Text = "" Then
Label3.Text = "PLEASE ENTER A USERNAME AND PASSWORD"
End If
If NameField.Text = "" And PasswordField.Text.Length > 0 Then
Label3.Text = "PLEASE ENTER A NAME"
End If
If PasswordField.Text = "" And NameField.Text.Length > 0 Then
Label3.Text = "PLEASE ENTER A PASSWORD"
End If
'generage first password
If Setting.DBpassword = "" Then
'save password here
password = PasswordField.Text
Setting.DBpassword = password
Setting.Save()
Else
End If
'generate first username
If Setting.DBUsername = "" Then
username = NameField.Text
Setting.DBUsername = username
Setting.Save()
Else
End If
'check if correct name and password are entered
If PasswordField.Text = Setting.DBpassword And NameField.Text = Setting.DBUsername Then
Label3.Text = ("WELCOME " & NameField.Text)
Dim itm As Control
Me.Close()
For Each itm In MLGMain.Controls
itm.Enabled = True
Next
End If
If NameField.Text.Length >= 1 And NameField.Text <> Setting.DBUsername And PasswordField.Text.Length >= 1 And NameField.Text <> Setting.DBpassword Then
Label3.Text = "INCORRECT USERNAME AND PASSWORD COMBINATION"
NameField.Clear()
PasswordField.Clear()
End If
End Sub
End Class
You'll need some sort of mechanism to count the admin logins. You could set up a SQL server table on the LAN that would be accessed by all the computers. This table would maintain information about who is logged into the system. You would need to make sure that they are properly logged out at the end of the session.