c#, read user session from event log

Hi,

First, I am not sure if it is possible to get session information from event log of Windows. I am in need to read user session logs like when new user log in or log out.

Is it possible?

Thanks
josephm67Asked:
Who is Participating?
 
CodeCruiserConnect With a Mentor Commented:
Are you talking about Windows user login? This info is captured in the Security node of event viewer.
0
 
käµfm³d 👽Commented:
What "session information" are you looking for?
0
 
josephm67Author Commented:
I m looking for login and log out info of users
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
jorge_torizResearch & Development ManagerCommented:
Do you want to create a new record on Windows Event Log when a user log in or log out?
0
 
josephm67Author Commented:
Yes, I need to grab it and then put it in database. Is it possible?
0
 
jorge_torizConnect With a Mentor Research & Development ManagerCommented:
Yes, you can do that, but first I need to know if you are working on a desktop application or a web application?

Meanwhile I can give you the following code:

During log in process
System.Diagnostics.EventLog.WriteEntry("YourApp", "User USERNAME logged in");
DBStoreLogIn("USERNAME");

During log out process
System.Diagnostics.EventLog.WriteEntry("YourApp", "User USERNAME logged out");
DBStoreLogOut("USERNAME");
0
 
josephm67Author Commented:
It is desktop app. But, I want to grab the event. Is it possible to grab the event.

thanks
0
 
jorge_torizConnect With a Mentor Research & Development ManagerCommented:
Event... what do you mean with "event"?, is there an event like "user_logged_in"? I can't depict the event you need to handle.

As far as I know you could write that pseudo-code in your authentication function, so you will be able to store the event on wherever you want.
0
 
josephm67Connect With a Mentor Author Commented:
What is authentication function?
You are talking about something else, I guess. I need to grad windows event when user log in to server or log out. Are you talking same?
0
 
josephm67Author Commented:
thanks
0
All Courses

From novice to tech pro — start learning today.