Click here to Skip to main content
15,799,491 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

I need the client computer name or windows logged on user name. So how to get it?

I have tried so many ways. Its working in local. But, but not working after deploying in server. Please do needful.
Posted
Updated 29-Oct-10 2:19am
v2

Hi Toni,

Are you looking in presepective of Internet application or Intranet application ?

For Internet application:-

To get the machine name and logged in user id, you need to develop one COM/ActiveX Componnet which must sit on the machine of user i.e. the client machine. COM/ActiveX component should sense the computer name & the logged in user and post that information to your web application.

BTW, You can get the Requesting Client IP address from the HTTP Request variable in your web pages but that would give you the internet service providers IP address/Name.

Thanks
CP
 
Share this answer
 
Comments
Toniyo Jackson 29-Oct-10 7:41am    
Intranet app
You can see this links

Click

Click
 
Share this answer
 
Request.ServerVariables["REMOTE_HOST"][^]

click the link for further reading
 
Share this answer
 
This should do it...

C#
using System;
using System.Management;
using System.Windows.Forms;
namespace MyComputerName
{
    public class GetComputerName
    {
        public static void Main()
        {
            try
            {
                ManagementObjectSearcher searcher =
                    new ManagementObjectSearcher("root\\CIMV2",
                    "SELECT * FROM Win32_ComputerSystem");
                foreach (ManagementObject queryObj in searcher.Get())
                {
                    Console.WriteLine("Client Computer Name is : {0}", queryObj["Name"]);
                }
            }
            catch (ManagementException e)
            {
                MessageBox.Show("Oops ! ERROR : " + e.Message);
            }
        }
    }
}
 
Share this answer
 
Comments
Toniyo Jackson 29-Oct-10 7:30am    
thanx. i think this is for win forms. i need the code for web application.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900