Solved

dsquery - last logon

Posted on 2011-09-30
3
7,118 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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Always backup Domain, SYSVOL etc.using processes according to Microsoft Best Practices. This is meant as a disaster recovery process for small environments that did not implement backup processes and did not run a secondary domain controller that ne…
Uncontrolled local administrators groups within any organization pose a huge security risk. Because these groups are locally managed it becomes difficult to audit and maintain them.
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Suggested Courses

630 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