User Logged onto Windows
As per my second comment, below is a possible solution. This solution involves a different querying method that will work for both console sessions and remote sessions. This method looks at all processes that are the explore.exe process, which is the user shell for each user that is logged into the server.  Once armed with the list of those processes, getting the owner for it is another WMI query (GetProcessOwner method).

// what to do if multiple users logged in?
foreach (var p in Process.GetProcessesByName("explorer"))
{
    _username = GetProcessOwner(p.Id);
}

// remove the domain part from the username
var usernameParts = _username.Split('\\');

_username = usernameParts[usernameParts.Length - 1];


...

    public static string GetProcessOwner(int processId)
    {
        var query = "Select * From Win32_Process Where ProcessID = " + processId;
        ManagementObjectCollection processList;

        using (var searcher = new ManagementObjectSearcher(query))
        {
            processList = searcher.Get();
        }

        foreach (var mo in processList.OfType&lt;ManagementObject&gt;())
        {
            object[] argList = { string.Empty, string.Empty };
            var returnVal = Convert.ToInt32(mo.InvokeMethod("GetOwner", argList));

            if (returnVal == 0)
            {
                // return DOMAIN\user
                return argList[1] + "\\" + argList[0];
            }
        }

        return "NO OWNER";
    }