Re: Get Windows Logon User from inside a windows service
- From: "William DePalo [MVP VC++ ]" <willd.no.spam@xxxxxxxx>
- Date: Sun, 18 Dec 2005 11:56:58 -0500
"Andreas" <Andreas@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:0AFEE34B-926C-4933-B776-0E951CB7DD37@xxxxxxxxxxxxxxxx
>I am writting a windows service that records the user activity. (logon and
> logoff at the time being)
> The service is user the local system account on all PCs of the domain.
>
> Within this service i am getting the IP address of the PC and i also want
> to
> get the user name of the user that loged on to windows .
>
> I tried the code below
>
> UserName=System.Security.Principal.WindowsIdentity.GetCurrent.Name.ToString
>
> but it returns the user that the service is using (Local System Account).
>
> How can I get the user name of the user who logged on to windows?
You have two choices. Either you insinuate yourself into the logon process
or you have a helper send notifications to your service.
The latter option is easier - add a registry entry here
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
to launch an application on every login which waits for the WM_ENDSESSION to
exit. On launch or exit it sends a notification to your service.
For the former option you might want to start reading here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/secauthn/security/customizing_winlogon.asp
Regards,
Will
.
- Prev by Date: Waitable Timers
- Next by Date: Re: Get Windows Logon User from inside a windows service
- Previous by thread: Waitable Timers
- Next by thread: Re: Get Windows Logon User from inside a windows service
- Index(es):
Relevant Pages
|