Determining When a User Last Logged On - 28 Jul 2008

Q: How can I find a user’s last logon time in a Windows domain? Where is a user’s last logon time stored in Active Directory (AD)?

A: AD stores a user’s last logon time in the Last-Logon AD user object attribute. As with the logging of account logon events, the last logon time is updated only in the AD instance of the domain controller (DC) that actually authenticated the user, meaning you must query all the DCs in the domain in which the user’s account is defined to find his last logon time. (See also, "How can I generate a list of last user logon times for a domain?" and "Q: Does Windows include a mechanism to show failed logon information to the user at logon time?").

Microsoft included a new AD user object attribute called Last-Logon- TimeStamp in Windows Server 2003. The Last-Logon-TimeStamp attribute stores the approximate value of the last logon time of a user. The value is approximate because AD replicates the Last-Logon-TimeStamp attribute only once every 14 days to avoid replication overhead. Although the Last-Logon- TimeStamp doesn’t resolve the problem that you must query all DCs in the user’s domain if you want to know the exact last logon time, it does give administrators a way to discover inactive or stale accounts. The Last-Logon-TimeStamp attribute is activated only when the domain is switched to the Windows 2003 domain functional level. For more information about Last-Logon-TimeStamp and to download sample scripts to query the value of the Last-Logon-TimeStamp attribute of a given user, go to www.microsoft.com/technet/scriptcenter/topics/win2003/lastlogon.mspx.

You can also view the value of Last- Logon-TimeStamp for a given user from the Microsoft Management Console (MMC) Active Directory Users and Computers snap-in if you install a special DLL called acctinfo.dll. This DLL is included in the Account Lockout and Management Tools, which can be downloaded from www.microsoft.com/downloads/details.aspx?FamilyID=7AF2E69C-91F3-4E63-8629-B999ADDE0B9E&displaylang=en. Acctinfo.dll adds the Additional Account Info tab to an AD user account’s properties, as shown in Figure 1. The Additional Account Info tab contains different types of account logon and logoff information, including the value of the Last-Logon- TimeStamp attribute.

—Jan De Clercq

Discuss this Article 4

dakiva
on Aug 14, 2008
Hi again. Please disregard my last question. Of course, I had to use regsvr32 to register the DLL. Thank you for the nice tip. This new tab could be handy in my environment.
dakiva
on Aug 14, 2008
Hi, That's a great tip. Thank you for the info. Do I need to copy acctinfo.dll to the System32 folder in order to add the "Additional Account Info" tab in AD? Thanks!

Please or Register to post comments.

IT/Dev Connections

Las Vegas
September 30th - October 4th

Paul ThurottYou'll have the opportunity to experience:
• The Microsoft
Technology Roadmap
• Office 365 Implementation
• Hyper-V Optimizing
• Windows 8 Deployment
and much more!

Come See Paul Thurrott & Rod Trent in Person!

Early Registration Now Open

Upcoming Training

Mastering System Center 2012

During over 6 hours of training you can join John Savill from your computer as he will walk you through the key components and capabilities of System Center 2012, what’s involved in using the components, and the benefit they can bring to your environment.

Register Now

Current Issue

May 2013 - The NameTranslate object is useful when you need to translate Active Directory object names between different formats, but it's awkward to use from PowerShell. Here's a PowerShell script that eliminates the awkwardness.

CURRENT ISSUE / ARCHIVE / SUBSCRIBE

Windows Forums

Get answers to questions, share tips, and engage with the Windows Community in our Forums.