Re: winnt provider and lastlogin using vbscript




"Richard Mueller [MVP]" <rlmueller-nospam@xxxxxxxxxxxxxxxxxxxx> wrote in
message news:%2321OkDm8IHA.4924@xxxxxxxxxxxxxxxxxxxxxxx

<awrightus@xxxxxxxxxxx> wrote in message
news:1458b1bf-feb4-4074-a313-9ab47eb14458@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I have a Windows 2003 workgroup server. No AD, domain, etc. In my
login script, using vbscript, I need to be able to tell the user when
they last logged on. I thought I had this licked by using the winnt
provider and the lastlogin attribute. However, during the login
process, it appears as if lastlogin has already been updated to the
current time, completely having overwritten what I was trying to
capture. During the user login process, is there any other attribute
that I can grab that will tell me when the user last logged in?
Thanks.

I noticed the same thing some time ago. There is no other attribute you
can use. The only thing I can think if is to save the date/time for future
use. Since this is a local account, you could save the information in a
text somewhere on the computer everyone has access to, perhaps in a file
named after the username.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


A quick VBScript example below. There are many other ways, but all involve
saving the logon date/time yourself somewhere the user has permissions:
=========
Option Explicit
Dim objNetwork, strName, strFile, objFSO, objFile
Dim strLast

Const ForReading = 1

' Retrieve user name.
Set objNetwork = CreateObject("Wscript.Network")
strName = objNetwork.UserName

' Specify local log file for this user.
strFile = "c:\scripts\" & strName & ".log"
Set objFSO = CreateObject("Scripting.FileSystemObject")

' Read the file if it exists.
' Trap the error if it does not exist.
On Error Resume Next
Set objFile = objFSO.OpenTextFile(strFile, ForReading)
If (Err.Number = 0) Then
On Error GoTo 0
' Read the last logon date/time and display.
strLast = objFile.ReadLine
objFile.Close
Call MsgBox("You last logged on at " & strLast)
End If
On Error GoTo 0

' Save the new last logon date/time in the log file.
Set objFile = objFSO.CreateTextFile(strFile, True)
objFile.WriteLine CStr(Now())
objFile.Close

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


.



Relevant Pages

  • Re: Bad update - X11 corrupted
    ... OK, there was no 'rhgb' in my boot loader, so I got in and manually ... the log file, but no help there. ... When the login prompt comes up, ... >> there, so keeps cycling from text login to graphical login and back, ...
    (Fedora)
  • Re: Installation of Silverlight
    ... Boot to safe mode and login as Administrator ... Create a New adminstrator account ... Error opening installation log file. ...
    (microsoft.public.windowsupdate)
  • Re: Best Way to Do Shared Logins
    ... The date and time was 11/18/2008 5:00 PM, and on a whim, Terry R. pounded out on the keyboard: ... What I am thinking about is a shared login, and then maybe some kind of custom process like a script or custom developed application that forces the user to provide his or her individual login information. ... The custom process would not do any authentication, but would verify that the login is valid and then log the information to a log file somewhere that the users would not be able to access. ...
    (microsoft.public.windowsxp.general)
  • Re: Need help: perl script to FTP
    ... > On the game server is log file which contains all of the data from the ... > on my webserver, which is supposed to login to the gameserver and download ... The &sendsubroutine doesn't exist in your script. ...
    (perl.beginners)
  • Re: Need help: perl script to FTP
    ... > On the game server is log file which contains all of the data from the ... > on my webserver, which is supposed to login to the gameserver and download ... The &sendsubroutine doesn't exist in your script. ...
    (comp.lang.perl)