Hi all,
I want to write a window service that send the email as soon as the user will logged in into the system(Computer).
I want to know the user and the time i.e. at what time he/she logs in.
With the help of system.security,principal i get the current user but how to get the loggin time.
Pease help!
Loading


VulpesRank #55 · 29.2K reputationPosted May 13, 2011, 6:45 AM EDT
VulpesRank #55 · 29.2K reputationPosted May 12, 2011, 5:13 AM EDT
Vijay YadavRank #1,637 · 943 reputationPosted May 13, 2011, 4:35 AM EDT
It's working but i want the user name of the system, it is giving LogonId as "NT AUTHORITY\SYSTEM". I have attached file please see it!
Suthish NairRank #92 · 22.8K reputationPosted May 13, 2011, 8:49 AM EDT
Sam HobbsRank #107 · 20.5K reputationPosted May 13, 2011, 3:05 PM EDT
Vijay YadavRank #1,637 · 943 reputationPosted May 20, 2011, 11:00 PM EDT
Thanks for your reply!
@Vulpes - I tried this way but it is not going in 1st foreach loop when i debug. Hence no result.
@Suthish - Yes, you are right.
@Sam - There is in-built service but i need to create one.
Sorry!!! for late reply guys.
Sam HobbsRank #107 · 20.5K reputationPosted May 20, 2011, 11:45 PM EDT
VulpesRank #55 · 29.2K reputationPosted May 21, 2011, 2:21 AM EDT
var mos = new ManagementObjectSearcher("SELECT * FROM win32_LogonSession ");
as evidently there are no sessions with a LogonType of 2 ('interactive') running on your machine.
See here(http://msdn.microsoft.com/en-us/library/aa394189(VS.85).aspx) for the types of sessions which are supported if you want to do your own filtering.
Vijay YadavRank #1,637 · 943 reputationPosted May 21, 2011, 3:10 AM EDT
With the help of Logontype=10, its working.
It is use for both remote and interactive.
Anyway thanks a lot!
VulpesRank #55 · 29.2K reputationPosted May 21, 2011, 4:28 AM EDT
Vijay YadavRank #1,637 · 943 reputationPosted May 21, 2011, 4:40 AM EDT