locked
How do I get the date and time a user logged in and the date and time they last logged in? RRS feed

  • Question

  • User1177026165 posted

    Hi

    I am building a web app, and I have a user info screen, which I want to show the date and time they loggied in along with the date time and they last logged in from Active Directory. Looking around the internet, I have tried using MembershipUser user = MembershipUser.GetUser(login); but when I tried using user to get the last login date, I wasn't getting any methods!

    Can anyone advise me how to get the date and times from Active Directory? I would really like to crack this!

    Thanks

    Thursday, July 16, 2009 4:46 PM

Answers

  • User-2009597737 posted

    Try lastlogontimestamp. You should get the data in the form of "ADticks", there is a simple function to convert this to date-time.


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 24, 2009 9:06 AM

All replies

  • User-588004917 posted

    Andy,

    Try this:

    MembershipUser mu = Membership.GetUser("test", false);
    DateTime lastLogin = mu.LastLoginDate;

    Thursday, July 16, 2009 4:52 PM
  • User1177026165 posted

    This is what I tried already, but never gave back any methods.

    Thursday, July 16, 2009 4:58 PM
  • User-2009597737 posted

    Try lastlogontimestamp. You should get the data in the form of "ADticks", there is a simple function to convert this to date-time.


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, July 24, 2009 9:06 AM