C# Windows Service, Detect Login

  • Thread starter Thread starter Frank Gibbs
  • Start date Start date
F

Frank Gibbs

What will tell me that a logon event has occured in a windows service. I
don't need full credtitals just NT User Name.

Frank
 
Frank,

The only workaround I can think of for this would be to place an
application in the startup directory for a user. Then, when the user logs
in, the application will start, and send a message to your service.

The only other way to do this would be to replace GINA.dll (which is
used on windows machines for authenitication purposes), but that requires
unmanaged code, which C# can not produce.

Hope this helps.
 
Frank Gibbs said:
What will tell me that a logon event has occured in a windows service. I
don't need full credtitals just NT User Name.

Frank

On XP and higher you can use "local policies" to turn on "Logon auditing",
this will log the Logon event into the security eventlog. Your service can
then read the eventlog at regular intervals (and parse Message ID
551=Logoff, 528 = Logon) or, you can use System.Management's namespace
ManagementEventWatcher and WMI to listen for security log events.
Another option, again on XP and higher) is the use System.Management's and
watch for Win32_LogonSession (WMI) instance creation events.

Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top