Page 3 of 3 FirstFirst 123
Results 21 to 24 of 24

Thread: Visual Basic Question: Login/Password Authentication

  1. #21
    ya, correct, i am in vb class right now, and i showed my teacher this thread and he agrees with my awnser, its right

  2. #22
    AO Antique pwaring's Avatar
    Join Date
    Aug 2001
    Posts
    1,409
    Delta4ce: You cannot decompile executable files and expect to be presented with the Visual Basic code, otherwise what's to stop everyone decompiling Windows and stealing stuff from it?

    Sure, you can disassemble an executable, but that won't help you much if you want to learn VB.
    Paul Waring - Web site design and development.

  3. #23
    thats not what i am talking about, i was talking about his database problem, i know u can't decompile exe's and get the vb u want !! i wasn't talkin about that.

  4. #24
    Senior Member Maestr0's Avatar
    Join Date
    May 2003
    Posts
    604
    Ok, this is un-secure and crappy coding but I just slapped some stuff together so you can figure out how it works, wouldn't want you to fail your class. By the way VB isnt my thing so theres probably I better way, but nothing came to mind. This logs some stuff in the DB about failed attempts etc.

    Globals:

    Public MyConnect As New ADODB.Connection 'For Queries
    Public MyRecordset As New ADODB.Recordset 'For Queries
    Public cmd As New ADODB.Command

    Public Const ConnectString = "provider=Microsoft.Jet.OLEDB.4.0; data source=SomeAccessDB.mdb"
    Public LogonTries As Integer


    Some login form:

    Private Sub Command3_Click(Index As Integer)
    Dim Tries As Integer, EventNumber As Single
    Dim User As String, Pin As Single
    Pin = 0
    If LogonTries < 3 Then
    User = Text1
    Pin = Val(Text2)
    '*** Grab Event Number (If there isn't one set to 0)

    cmd.CommandText = "SELECT EventNo FROM Loginout"
    MyRecordset.Open cmd, , adOpenDynamic, adLockBatchOptimistic
    If MyRecordset.EOF Or MyRecordset.BOF Then
    EventNumber = 0
    Else
    MyRecordset.MoveLast
    EventNumber = MyRecordset!EventNo + 1
    End If
    MyRecordset.Close
    ' ***
    ' *** Now See if Customer Exists with that PIN

    cmd.CommandText = "SELECT * FROM Customers WHERE CustID = " & Chr(34) & User & Chr(34) & " AND CustPIN = " & Pin
    MyRecordset.Open cmd, , adOpenDynamic, adLockBatchOptimistic
    ' *** Is there a record?
    If MyRecordset.EOF Or MyRecordset.BOF Then
    LogonTries = LogonTries + 1
    Debug.Print "Invalid Login"
    MyConnect.BeginTrans
    MyConnect.Execute "INSERT INTO Loginout (EventNo,EventType,EventID,EventDate) values (" & EventNumber & "," & Chr(34) & "Invalid Log-in " & Chr(34) & "," & Pin & "," & Date & ")"
    EventNumber = EventNumber + 1
    ' Increment Event
    MyRecordset.UpdateBatch
    MyConnect.CommitTrans
    MyRecordset.Close
    Text1.Text = ""
    Text2.Text = ""
    FailLogon.Show

    Else
    Debug.Print "ID accepted"
    MyConnect.BeginTrans
    MyConnect.Execute "INSERT INTO Loginout (EventNo,EventType,EventID,EventDate) values (" & EventNumber & "," & Chr(34) & "ID Accpeted " & Chr(34) & "," & Pin & "," & Date & ")"
    EventNumber = EventNumber + 1
    'Increment Event
    MyRecordset.UpdateBatch
    MyConnect.CommitTrans
    MyRecordset.Close

    ' *** This means we've logged in succesfully

    ActiveUserID = User 'Set Global Variable to keep track of User
    Inquiry.Show

    End If

    '**** LoginTries has exceded 3

    Else
    cmd.CommandText = "SELECT EventNo FROM Loginout"
    MyRecordset.Open cmd, , adOpenDynamic, adLockBatchOptimistic
    If MyRecordset.EOF Or MyRecordset.BOF Then
    EventNumber = 0
    Else
    MyRecordset.MoveLast
    EventNumber = MyRecordset!EventNo + 1
    End If
    MyConnect.BeginTrans
    MyConnect.Execute "INSERT INTO Loginout (EventNo,EventType,EventID,EventDate) values (" & EventNumber & "," & Chr(34) & "Log-in Attempts Exceded" & Chr(34) & "," & Pin & "," & Date & ")"
    MyRecordset.UpdateBatch
    MyConnect.CommitTrans
    MyRecordset.Close
    ' *** Account Lock Out msg and Exit program
    MsgBox ("Attempts Exceded")
    Dim AForm As Form
    For Each AForm In Forms
    Unload AForm
    Next
    End


    End If
    End Sub


    Private Sub Form_Load()

    Set MyConnect = New Connection
    With MyConnect
    .ConnectionTimeout = 10
    .Open ConnectString
    End With

    cmd.ActiveConnection = MyConnect
    End Sub




    If you cant figure it out from this, I cant help you. Hope this helps you out.
    -Maestr0
    \"If computers are to become smart enough to design their own successors, initiating a process that will lead to God-like omniscience after a number of ever swifter passages from one generation of computers to the next, someone is going to have to write the software that gets the process going, and humans have given absolutely no evidence of being able to write such software.\" -Jaron Lanier

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •