Tim,
 
In Windows 2000, that's a bit of a toughie - as the information is not stored in a replicated attribute.  What this means (you, I think know....) is that you have to query each DC to determine this information.  In Windows Server 2003, this changed - a timestamp attribute is now replicated - but it's not guaranteed to be accurate any closer than a week, as I understand it.  But, it's better than the unreliable nature of what is currently in place.
 
As an example of what you could do (credit to Rod Trent for this code):
 
On Error Resume Next
Dim User
Dim UserName
Dim UserDomain
UserDomain = InputBox("Enter the name of the domain:")
UserName = InputBox("Enter the name of the user:")
Set User = GetObject("WinNT://" & UserDomain & "/" & UserName & ",user")
MsgBox "The last time " & UserName & " logged on was: " & vbCRLf & vbCRLf & User.LastLogin
 
Note that this code does not take into account the fact taht you need to parse through and query all DC that the user could have authenticated against.  But, the code DOES work - however, if the user you are looking for has not authenticated against the DC that is queried then the user (for all you know) has never logged on.  :-/
 
Good luck!
 

Rick Kingslan  MCSE, MCSA, MCT
Microsoft MVP - Active Directory
Associate Expert
Expert Zone - www.microsoft.com/windowsxp/expertzone
 

 
 
 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Wright, T. MR NSSB
Sent: Thursday, July 17, 2003 8:07 PM
To: '[EMAIL PROTECTED]'
Subject: [ActiveDir] Last Logon Script

Does anyone have a script that will query an OU and tell me when the users last logged on? Or for that matter?  If they have logged on at all.
 
Thanks,
 
-Tim

Reply via email to