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


source to share





All Articles