By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,222 Members | 1,129 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,222 IT Pros & Developers. It's quick & easy.

Log Users both compteted and failed...

P: n/a
I would like to setup a form that will log the users logging in to a
db. The form and the Db will currently log the users if they complete
the logon and get in. It will then log the entry, but not if they
fail to login. If they fail I would like it to log the attempted pass
and the computer name from where they are logging in, the systems are
both win2k and win98 under access 2K.

for ex

User: User1
Pass: password

User gets in
DB shows, user1 pass ComputerName Work2 at 10:00am 09-29-03

User: User2
Pass: fail "entered the wrong pass"

User asked to relogin
DB shows, user2 Failed "fail" ComputerName work1 10:01am 09-29-03
Nov 12 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hi Chuck,
This code will only work if the login succeeded, won't it?
I can't think of code that logs the unsucceeded attempts, or am I missing something here?
I also count and log the number of users, machinename and so on, but not for attempts to log in.
Could be interesting though.

Arno R

"Chuck Grimsby" <c.*******@worldnet.att.net.invalid> schreef in bericht
news:eo********************************@4ax.com...

This is my "standard" logging function. Usually I write to a CSV file
rather then to a table in the database. This gets around "permission"
problems, and allows the Network Administrator (or whoever) to take a
look at what's going on with the database without having to give them
a login (and possibly access to data they shouldn't have access to!)

See http://www.mvps.org/access/api/api0008.htm for the code to get the
Network User name and http://www.mvps.org/access/api/api0009.htm for
the code to get the Machine name if you don't already have it.

Public Sub WriteToLog(strLogEntryText As String, _
Optional strSeperator As String = ",", _
Optional strLogFileName As String = "", _
Optional whatDB As DAO.Database = Nothing)

Dim intFF As Integer
Dim strSQL As String
Dim bolISetTheDB As Boolean

On Error Resume Next

If strLogFileName = "" Then
If whatDB Is Nothing Then
Set whatDB = CurrentDb
bolISetTheDB = True

' if no log name is given, create a log
' in the same location and with the same name
' as the database, but change the ext to '.dat'
strLogFileName = Left$(CurrentDb.Name, _
Len(CurrentDb.Name) - 4) & _
".dat"
Else
strLogFileName = Left$(whatDB.Name, _
Len(whatDB.Name) - 4) & _
".dat"
End If
End If

strSQL = Chr$(34) & Format$(Now(),"yyyy-mm-dd hh:nn:ss") & _
Chr$(34) & strSeperator & _
Chr$(34) & CurrentDb.Properties("AppTitle") & _
Chr$(34) & strSeperator & _
Chr$(34) & GetNetworkUserName() & _
Chr$(34) & strSeperator & _
Chr$(34) & GetMachineName() & _
Chr$(34) & strSeperator & _
Chr$(34) & strLogEntryText & _
Chr$(34)

intFF = FreeFile
Open strLogFileName For Append As intFF
Print #intFF, strSQL
Close intFF

If bolISetTheDB = True Then
whatDB.Close
Set whatDB = Nothing
End If

On Error GoTo 0
End Sub
On 29 Sep 2003 12:43:38 -0700, jo***********@socal.rr.com (Josh
Armstrong) wrote:
I would like to setup a form that will log the users logging in to a
db. The form and the Db will currently log the users if they complete
the logon and get in. It will then log the entry, but not if they
fail to login. If they fail I would like it to log the attempted pass
and the computer name from where they are logging in, the systems are
both win2k and win98 under access 2K.

for ex

User: User1
Pass: password

User gets in
DB shows, user1 pass ComputerName Work2 at 10:00am 09-29-03

User: User2
Pass: fail "entered the wrong pass"

User asked to relogin
DB shows, user2 Failed "fail" ComputerName work1 10:01am 09-29-03

--
He Who Laughs Last Thinks Slowest!

Nov 12 '05 #2

P: n/a
I don't believe there's any way to log failed logins. Access doesn't start
running until after the validation process, so you can't use VBA code in
your application to do that kind of logging.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
"Arno R" <ar****************@tiscali.nl> wrote in message
news:bl*********@reader1.tiscali.nl...
Hi Chuck,
This code will only work if the login succeeded, won't it?
I can't think of code that logs the unsucceeded attempts, or am I missing something here? I also count and log the number of users, machinename and so on, but not for attempts to log in. Could be interesting though.

Arno R

"Chuck Grimsby" <c.*******@worldnet.att.net.invalid> schreef in bericht
news:eo********************************@4ax.com...

This is my "standard" logging function. Usually I write to a CSV file
rather then to a table in the database. This gets around "permission"
problems, and allows the Network Administrator (or whoever) to take a
look at what's going on with the database without having to give them
a login (and possibly access to data they shouldn't have access to!)

See http://www.mvps.org/access/api/api0008.htm for the code to get the
Network User name and http://www.mvps.org/access/api/api0009.htm for
the code to get the Machine name if you don't already have it.

Public Sub WriteToLog(strLogEntryText As String, _
Optional strSeperator As String = ",", _
Optional strLogFileName As String = "", _
Optional whatDB As DAO.Database = Nothing)

Dim intFF As Integer
Dim strSQL As String
Dim bolISetTheDB As Boolean

On Error Resume Next

If strLogFileName = "" Then
If whatDB Is Nothing Then
Set whatDB = CurrentDb
bolISetTheDB = True

' if no log name is given, create a log
' in the same location and with the same name
' as the database, but change the ext to '.dat'
strLogFileName = Left$(CurrentDb.Name, _
Len(CurrentDb.Name) - 4) & _
".dat"
Else
strLogFileName = Left$(whatDB.Name, _
Len(whatDB.Name) - 4) & _
".dat"
End If
End If

strSQL = Chr$(34) & Format$(Now(),"yyyy-mm-dd hh:nn:ss") & _
Chr$(34) & strSeperator & _
Chr$(34) & CurrentDb.Properties("AppTitle") & _
Chr$(34) & strSeperator & _
Chr$(34) & GetNetworkUserName() & _
Chr$(34) & strSeperator & _
Chr$(34) & GetMachineName() & _
Chr$(34) & strSeperator & _
Chr$(34) & strLogEntryText & _
Chr$(34)

intFF = FreeFile
Open strLogFileName For Append As intFF
Print #intFF, strSQL
Close intFF

If bolISetTheDB = True Then
whatDB.Close
Set whatDB = Nothing
End If

On Error GoTo 0
End Sub
On 29 Sep 2003 12:43:38 -0700, jo***********@socal.rr.com (Josh
Armstrong) wrote:
I would like to setup a form that will log the users logging in to a
db. The form and the Db will currently log the users if they complete
the logon and get in. It will then log the entry, but not if they
fail to login. If they fail I would like it to log the attempted pass
and the computer name from where they are logging in, the systems are
both win2k and win98 under access 2K.

for ex

User: User1
Pass: password

User gets in
DB shows, user1 pass ComputerName Work2 at 10:00am 09-29-03

User: User2
Pass: fail "entered the wrong pass"

User asked to relogin
DB shows, user2 Failed "fail" ComputerName work1 10:01am 09-29-03

--
He Who Laughs Last Thinks Slowest!


Nov 12 '05 #3

P: n/a
jo***********@socal.rr.com (Josh Armstrong) wrote in message news:<b6**************************@posting.google. com>...
I would like to setup a form that will log the users logging in to a
db. The form and the Db will currently log the users if they complete
the logon and get in. It will then log the entry, but not if they
fail to login. If they fail I would like it to log the attempted pass
and the computer name from where they are logging in, the systems are
both win2k and win98 under access 2K.

for ex

User: User1
Pass: password

User gets in
DB shows, user1 pass ComputerName Work2 at 10:00am 09-29-03

User: User2
Pass: fail "entered the wrong pass"

User asked to relogin
DB shows, user2 Failed "fail" ComputerName work1 10:01am 09-29-03


If ValidateUser(strUserName, strPassword)=True Then
LogAttempt(strUsername,ComputerName,Now(),True,"") 'True=blnSuccessful
Else
LogAttempt(strUserName,ComputerName,Now(),False,"W rong Password")
End if

Child's play.
Nov 12 '05 #4

P: n/a
From the responses I think I need to mention that I am not using the
built-in access control to access. This is a form with in the DB
itself. I can get it to log the logon attempts now, but only the ones
that get into the DB not the ones that fail. I don't seem to able to
get it to create a new record each time the user clicks the "log On"
button.

pi********@hotmail.com (Pieter Linden) wrote in message news:<bf**************************@posting.google. com>...
jo***********@socal.rr.com (Josh Armstrong) wrote in message news:<b6**************************@posting.google. com>...
I would like to setup a form that will log the users logging in to a
db. The form and the Db will currently log the users if they complete
the logon and get in. It will then log the entry, but not if they
fail to login. If they fail I would like it to log the attempted pass
and the computer name from where they are logging in, the systems are
both win2k and win98 under access 2K.

for ex

User: User1
Pass: password

User gets in
DB shows, user1 pass ComputerName Work2 at 10:00am 09-29-03

User: User2
Pass: fail "entered the wrong pass"

User asked to relogin
DB shows, user2 Failed "fail" ComputerName work1 10:01am 09-29-03


If ValidateUser(strUserName, strPassword)=True Then
LogAttempt(strUsername,ComputerName,Now(),True,"") 'True=blnSuccessful
Else
LogAttempt(strUserName,ComputerName,Now(),False,"W rong Password")
End if

Child's play.

Nov 12 '05 #5

P: n/a
jo***********@socal.rr.com (Josh Armstrong) wrote in message news:<b6**************************@posting.google. com>...
From the responses I think I need to mention that I am not using the
built-in access control to access. This is a form with in the DB
itself. I can get it to log the logon attempts now, but only the ones
that get into the DB not the ones that fail. I don't seem to able to
get it to create a new record each time the user clicks the "log On"
button.

Say you have a form like this:

UserName: [ ]
Password: [ ]

[Log In] [Cancel]
The cmdLogIn button will do something like the following:

dim blnLoginOK as Boolean
dim rs as dao.recordset
dim db as dao.database

set db=currentdb
'open the table for adding records
set rs=db.opentable("tblLogons",dbOpenTable)

'determine if the password matched
blnLogInOK = ValidateUser(me.UserName,me.Password)

'Log the attempt, successful or not.
rs.AddNew
rs.Fields("UserName")=Me.UserName
rs.Fields("Successful")=blnLogInOK
rs.Fields("TimeStamp")=Now
rs.Update

'Clean up
rs.close
set rs=nothing
set db=nothing
Nov 12 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.