Local service user logged into Windows

I created a Windows service that keeps track of which application server is actually connected to a user through a load balancer.

It retrieves the user who logs in to windows on this computer, then cross-references the Active Directory (AD) account to return first, last, and email (for notification via the website created for this project)

There is one system on the network where users are only deleted on the system, Vista System, for some reason it comes back with values ​​that say "LOCAL SERVICE" is registered on this machine, this is weird and the security guys say, which is not possible for the "LOCAL SERVICE" account to be registered in Windows.

This is how I get the user logged into Windows

ManagementScope ms = new ManagementScope("\\\\.\\root\\cimv2");
ObjectQuery query = new ObjectQuery("select * from win32_computersystem");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(ms, query);

foreach (ManagementObject mo in searcher.Get())
{
    _username = mo["username"].ToString();
}
// remove the domain part from the username
string[] usernameParts = _username.Split('\\');
_username = usernameParts[usernameParts.Length - 1];

      

is an edge case that I can fix, or the user is actually "logged in" on this computer.

Are there many users logged into this machine and Vista lists "LOCAL SERVICE" as one of them?

Cross-reference to CodeReview

+3
windows-vista service windows-services


source to share


No one has answered this question yet

Check out similar questions:

485
How do I uninstall a Windows service if the files no longer exist?
57
How do I get the current username from a Windows service in .NET?
47
Error installing Windows service developed in .Net
40
How to start a process from a Windows service into the current user session
7
C # Running Windows Form Application from Service (and in Vista)
3
Installing Windows Service as User
1
printing PDF file in C # Windows Service under Local System Account
1
get the number of registered users in the system from the service
0
Windows Service Properties - Sign In
0
Windows service does not start as local user



All Articles
Loading...
X
Show
Funny
Dev
Pics