473,405 Members | 2,404 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,405 software developers and data experts.

Log Users both compteted and failed...

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
5 2708
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Viviana Vc | last post by:
How can I programatically do the equivalent of the following: cacls "C:\Program Files\test" /T /G Everyone:f ? Thanks, Viv
15
by: Viviana Vc | last post by:
How can I programatically do the equivalent of the following: cacls "C:\Program Files\test" /T /G Everyone:f ? Thanks, Viv
7
by: Reza | last post by:
Hello The project was working, where I had a domain user registered in the database as a user, and I used that user to connect the datebase. Everything was fine and it was working, then when I...
14
by: Viviana Vc | last post by:
How can I programatically do the equivalent of the following: cacls "C:\Program Files\test" /T /G Everyone:f ? Thanks, Viv
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.