Solved

dsquery - last logon

Posted on 2011-09-30
3
6,864 Views
Last Modified: 2012-05-12

The following gives me the last logon time of a user.  However, given the existence of products like “Real Last Logon”, my understanding is that the below query would need to be run on several domain controllers to get a accurate time.

dsquery * domainroot -filter "(&(objectCategory=Person)(objectClass=User)(sAMAccountName=%username%))" -attr sAMAccountName distinguishedName lastLogon

Can the dsquery tool target a specific domain controller to ease this burden?
0
Comment
Question by:Marketing_Insists
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 39

Accepted Solution

by:
Krzysztof Pytko earned 500 total points
ID: 36892991
Instead of lastLogon use lastLogonTimeStamp which is replicated between all DCs in a domain.
More about this attribut on a blog Ask DS at
http://blogs.technet.com/b/askds/archive/2009/04/15/the-lastlogontimestamp-attribute-what-it-was-designed-for-and-how-it-works.aspx

Regards,
Krzysztof
0
 
LVL 57

Expert Comment

by:Mike Kline
ID: 36893044
agree with Krzystof, what the tool you mentioned does hits every DC.  I haven't used it myself.

I'd use a tool like adfind http://www.joeware.net/freetools/tools/adfind/index.htm or the Quest powershsll cmdlets as they do a better job of decoding the dates


adfind -default -f "&(objectcategory=person)(objectclass=user)" samaccountname lastlogontimestamp -tdc -nodn

Thanks

Mike
0
 

Author Closing Comment

by:Marketing_Insists
ID: 36933734
Thanks, this was it
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This article demonstrates probably the easiest way to configure domain-wide tier isolation within Active Directory. If you do not know tier isolation read https://technet.microsoft.com/en-us/windows-server-docs/security/securing-privileged-access/s…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question