Dunkie
|
| Posted: 10/25/2002, 2:36 AM |
|
hi,
I'm writing code to trap user log ins to perform login audits. I'm able to trap bad attempts and correct attempts into two tables. However, I'm having a bit of a mess with trapping logout's (to enable me determine how long one was logged in). Any help most appreciated.
Excerpts from my code
Correct entry
'---------------------- Log Entry attempt -----------------------------
UserIP=request.serverVariables("remote_addr")
baddate=now()
UsrID=CLng(DLookUp("lookup_csa", "csa_id", "db_login =" & ToSQL(sLogin, "Text") & " and db_pass=" & ToSQL(sPassword, "Text")))
cn.execute("insert into adt_log_access (datetime_in,user_id,user_ip) values (now()," & ToSQL(UsrID,"Number") & "," & ToSQL(UserIP,"Text") & ")")
'---------------------- End Log Entry attempt -----------------------------
Wrong Attempt
'---------------------- Log Bad Entry attempt -----------------------------
badIP=request.serverVariables("remote_addr")
baddate=now()
badusID=CLng(DLookUp("lookup_csa", "csa_id", "db_login =" & ToSQL(sLogin, "Text") & " and db_pass=" & ToSQL(sPassword, "Text")))
baduser=getparam("Login")
badpass=getparam("Password")
cn.execute("insert into adt_log_wrongaccess (date_log,user_id,username,userpass,bad_ip) values (now()," & ToSQL(badusID, "Number") & "," & ToSQL(baduser, "Text") & "," & ToSQL(badpass, "Text") & "," &ToSQL(badIP,"Text") &")")
sfrmloginErr = "Login or Password is incorrect. Try again."
end if
'---------------------- End Bad Log Entry attempt -----------------------------
Logout
'---------------------- Logout Entry -----------------------------
UserIP=request.serverVariables("remote_addr")
MyUsr=CStr(DLast("adt_log_access", "user_id=" &Session("UserID")))
cn.execute("insert into adt_logout_access (user_id,user_ip) values (" & MyUsr & "," & ToSQL(UserIP,"Text") & ")")
'---------------------- End Logout Entry -----------------------------
I've tried various things with "MyUsr" but no luck I get blanks written to my table
|
|
|
 |
Nicole
|
| Posted: 10/28/2002, 7:00 AM |
|
Dunkie,
As I understand you need to retrieve the last date value of logged in user with given UserID value. Try to use dlookup() function:
'get the last record id
MyUsr_id = dlookup("adt_log_access", "max(record_id)", "user_id=" & Session("UserID"))
' get datetime value
MyUsr = dlookup("adt_log_access", "datetime_in", "record_id= " & MyUsr_id)
|
|
|
 |
Dunkie
|
| Posted: 10/30/2002, 1:31 AM |
|
Thnx Nicole!
However, I'm looking for the CCS equivalent... I tried using DLast and CCDLast but I don't seem to be going anywhere.
Thnx in adv.
|
|
|
 |
|