Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Temp Password

Status
Not open for further replies.

Lambro

Programmer
Aug 22, 2001
258
US
I have a user name and password login that uses a MS Access database. I want to know if it is possible to have a password expire in a certain time period. Say I change the password in the database and it records a timestamp. And I want it to expire 24 hours from the timestamp. Is this possible, are there any examples, thanks.
 
u may have to use windows task manager, is that o.k???

Known is handfull, Unknown is worldfull
 
Try this:
Code:
HourFactor = 0.041666666666667
CurDateTime = Now
ExpDateTime = CurDateTime + (HourFactor * 24) 'Expires after 24 hours

Response.Write "Current time is " & CurDateTime & "<br>"
Response.Write "Expires on " & ExpDateTime & "<br>"
 
ExpDateTime = CurDateTime + (HourFactor * 24) 'Expires after 24 hours


?????


how will that expire a variable in 24 hours? am i missing some function here???


Known is handfull, Unknown is worldfull
 
Hi, vbkris!

I maybe wrong, but as far as I can understand it, Lambros' problem is how to compute the expiry date/time -- not how to trigger the event. Right?
 
OK, I'm giving a more elaborate example.
Here's a sample code on how to set the password expiry date/time:
Code:
[blue]
userid = "myuserid"
userpassword = "mynewpassword"

HourFactor = 0.041666666666667
CurDateTime = Now
ExpDateTime = CurDateTime + (HourFactor * 24) [green]'Expires after 24 hours[/green]

Set oConn = Server.CreateObject("ADODB.connection")
oConn.Mode = 2
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" + _
           "Data Source=C:\MyDir\MyDB.mdb;"

set RS = server.CREATEOBJECT("ADODB.Recordset")
Rs.cursortype = 1   [green]'adOpenKeyset[/green]
Rs.cursorlocation = 2 [green]'adUseServer[/green]
Rs.locktype = 3  [green]'adLockOptimistic[/green]

Rs.Open "select * from MyPasswordTable where UserID='" + _
        userid + "'", oConn

if Rs.EOF then
  [green]' New user? Then create a new record[/green]
  Rs.AddNew
  Rs("userid")=userid
  Rs("userpassword")=userpassword
end if
Rs("expdatetime")=ExpDateTime
Rs.Update

Rs.Close
oConn.Close[/blue]

And here's a sample code on how to test if the password had expired:
Code:
[blue]
  [green]' get [b]userid[/b] and [b]password[/b] thru form SUBMIT[/green]
  userid = Request.Form("userid")
  userpassword = Request.Form("userpassword")
  currentdatetime = Now

  Set oConn = Server.CreateObject("ADODB.connection")
  oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" + _
             "Data Source=C:\MyDir\MyDB.mdb;"

  set RS = server.CREATEOBJECT("ADODB.Recordset")
  Rs.cursortype = 1   
  Rs.cursorlocation = 2 
  Rs.locktype = 3  
  
  Rs.Open "select * from MyPasswordTable where UserID='" + _
          userid + "'", oConn

  if Rs.EOF then
    response.write "Sorry, you're not a registered user."
  else
    if userpassword<>Rs("userpassword") then
      response.write "Incorrect password!"
    else
      if currentdatetime > Rs("ExpDateTime") then
        response.write "Hi, " + userid + "!<br>"
        response.write "Your current password has expired.<br>"
        response.write "You'll have to enter a new password."
      else
        response.write "Your current password is still valid."
      end if
    end if
  end if
  Rs.Close
  oConn.Close
[/blue]
 
but then ur method is not automated. i have to call the ASP file to set it...

Known is handfull, Unknown is worldfull
 
Yes, but you don't need to automate a password expiry date/time unlike a session. You only need to check it everytime you login, unless Lambro wants something else done when the password expires. If all you need is simply prompt the user to change the password when it has expired (since the last time the user logged in), this is a way to do it.

Cheers!

Medic
 
uhm ... for simplicity's sake, password expires in 24 hours? no spiffy anythings?

ok you have LastUpdated in the DB... and it's date time.

in your asp :

If RS("LastUpdated") < (Now()-1) Then
Response.Write "Password Expired"
End If

[thumbsup2]DreX
aKa - Robert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top