User's Last Login

  • I have an application in which I need to get a user's last login datetime. I don't know how to do this.

    For example, I have a table of users for a particular customer. The customer can access my application and see a list of their users. I need to go through the user list and see when the last time each user logged in - anyone know how I can do this?

  • This isn't necessarily stored anywhere. You could build a table to hold this and then set a DDL trigger on the server login event to update this table with GETDATE() based on the user's login.

  • Well it depends on how your application authenticates users.

    Does the application grant the user access to your database by using their windows login?

    or does the user physically have to type something in to get into your application?

    If its the former then it will be difficult to identify a login because depending on how the app has connections set up it could connect each time a request is made to the database. ultimately you'll have to build something that writes/updates a record indicating the login time.

    For the latter you'll have to modify your logon procedure to persist the time the logon occurred.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply