PDA

Click to See Complete Forum and Search --> : [2.0] Get user account that log to your PC.


mar_zim
Sep 14th, 2006, 09:27 PM
Hi guys good day. How can I get users account that log to my pc? I tried it in WMI using win32_useraccount but there's no luck. I want to retrieve information such as user account and the last time she/he logon. Links and article will do.



Thanks in advance guys.

ComputerJy
Sep 14th, 2006, 10:16 PM
I'm not sure how to do that pragmatically, but you must enable the "Audit Logon Events"
Control Panel==>Administrative Tools==>Local Security settings==>Local Policies==>Audit Policy
Set the "Audit Logon Events" to success and optionally failure
now all you have to do is read the events from the Event Log and filter the category for "logon/logoff" events and search for the user name between the strings "User Name:" and "Domain:"

mar_zim
Sep 14th, 2006, 10:33 PM
Thanks for the input mate. At least I see now on who log in my pc. My problem now is to get those information.

Hack
Sep 15th, 2006, 06:30 AM
Try this (http://www.codeproject.com/csharp/getusername.asp)

mar_zim
Sep 17th, 2006, 07:41 PM
Thanks for the great link hack. But it's seems it gets only the current user log in your pc not all the user and there's no specific log time of each user.


Can it be done in c# to enable the audit logon events?

Harsh Gupta
Sep 18th, 2006, 09:10 AM
Well I am not sure about it, but have you tried looking into WMI class "Win32_UserAccount" (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_useraccount.asp)??

There are 3 more similar WMI classes: Win32_UserDesktop (http://search.msdn.microsoft.com/search/Redirect.aspx?title=Win32_UserDesktop+class+%5bWMI%5d&url=http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_userdesktop.asp), Win32_SystemUsers (http://search.msdn.microsoft.com/search/Redirect.aspx?title=Win32_SystemUsers+class+%5bWMI%5d&url=http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_systemusers.asp), Win32_UserInDomain (http://search.msdn.microsoft.com/search/Redirect.aspx?title=Win32_UserInDomain+class+%5bWMI%5d&url=http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_userindomain.asp)

mar_zim
Sep 18th, 2006, 07:49 PM
I have here a wmi code creator from microsoft and go through that classes but no luck.