No announcement yet.

How to generate a "last login" report

  • Filter
  • Time
  • Show
Clear All
new posts

  • How to generate a "last login" report


    I would like to know how can I get a report of all users last login time?
    I would like to clean my Active directory from users who haven't login to the domain above X time.

    Thanks for your help

  • #2
    Re: How to generate a "last login" report

    Basically, use dsquery:
    Tom Jones
    MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
    IT Trainer / Consultant
    Ossian Ltd

    ** Remember to give credit where credit is due and leave reputation points where appropriate **


    • #3
      Re: How to generate a "last login" report

      goolge: dsquery lastlogontimestamp

      Because the lastLogon attribute is not replicated in Active Directory, a different value can be stored in the copy of Active Directory on each Domain Controller. If your domain is at Windows Server 2003 functional level or above, there is a new attribute called lastLogonTimeStamp you can use. Unlike the lastLogon attribute, this attribute is replicated in AD.

      Accuracy of LastLogon and LastLogonTimeStamp: (!)
      The lastLogon attribute is updated at every logon, but is not replicated. For each user a different value is saved on every Domain Controller. The only way to get a true value is to query every DC in the domain and compare to find the lated date.

      The lastLogonTimeStamp attribute is only updated if the old value is more than 14 days old (by default, the interval can be modified). However, once updated the value is replicated. You only need to query one DC but the value is accurate to within 14 days. For most purposes this is satisfactory.


      Last edited by Rems; 28th April 2013, 11:33.

      This posting is provided "AS IS" with no warranties, and confers no rights.


      ** Remember to give credit where credit's due **
      and leave Reputation Points for meaningful posts