We have an existing system in which a windows service, which is network service enabled, is hosted on a network service account on the server. There are windows services installed on every client which start automatically once a user logs in through each client and these services on client trigger the service on the server telling it that for e.g client A has logged in.
What i want to do is create a network service and host it on the server, and trigger it directly without installing a separate windows service on each client. Is it possible? I want each client to use the existing network service and inform it upon log-in that it is online. Sort of maintaining a user log-in log at the server with time.
I have made this using Simple Impersonation Library. Here is the snippet that I use on my WPF client.
This is useful if you want to trigger the service from your client. But if the service is already working and just want to respond to log in, then you could maintain a table of clients with a flag DidLoggedIn, and your windows service should have a long running task monitoring this flags. The idea here is that whenever the client logs in you will set the flag to true, and on your server side the windows service's long running task will detect this and well do whatever you want it to do.
Hope it helps
EDIT>>> I have an application that does so. Let me share some snippets.
startMonitorTask is the long running task to monitor the flags. CyclicalTask is just an extension method of my own:
StartAllWorkersAsync is the method than has the monitoring funcionality.
Where EdiDataAccess.GetEdiCostumersToStart(); retrieves all those customers that have requested to log in
This my window service can detect when a customer has requested to begin a session.