Link to home
Start Free TrialLog in
Avatar of Michael Sterling
Michael SterlingFlag for United States of America

asked on

How do I programmatically pull / access the computer name on any given machine (laptop / desktop) etc.?

How do I programmatically pull / access the computer name on any given machine (laptop / desktop) etc.?
Avatar of kaufmed
kaufmed
Flag of United States of America image

Are you referring to client machines that access your website? If so, is this an Intranet or Internet site?
ASKER CERTIFIED SOLUTION
Avatar of Matthew Kelly
Matthew Kelly
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
To expand on kaufmed's comment, if you are trying to get the computer name of client machines that access your website, it will only work for machines on your local network, as machine names are concept of local networks. If any of them connect via the internet to your server they won't give a machine name, just IP address.

To get client computer names of machines on your local network, you will need to use reverse DNS:

In C#:
string clientMachineName;
        clientMachineName = (Dns.GetHostEntry(Request.ServerVariables["remote_addr"]).HostName);
        Response.Write(clientMachineName);

In classic ASP you can use something like this: http://www.asp101.com/articles/jason/reversedns/default.asp
Avatar of Michael Sterling

ASKER

@kaufmed & @matthewstevenkelly: well i guess i'll need to get the IP address then. what i'm attempting to do is limit where (which machines) users can do certain things within my web site that will be eventually hosted on goDaddy. I only want certain functionality available if the user is on machine(s) x, y, z...is there a better way of doin this? how would this "plan" be affected if the user were to use a laptop?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Using the IP address is not a good method for authentication because it can be spoofed: http://en.wikipedia.org/wiki/IP_address_spoofing

Additionally, when multiple users are behind the same router, they will all appear to your website with the same IP address.

You can see this for yourself, if you have a home router, and more than one computer connected to it, go to http://www.whatismyip.com/ and they will both show the same IP address. And as mentioned previously, most users have a dynamic IP address, so it changes every time the router is rebooted.


You can get a users IP address in C# by using: Request.ServerVariables["remote_addr"]

But it should only be used as an FYI, not authentication.


If you don't need a lot of security, you could just use cookies to track the machine. Basically when the user goes to a website a cookie will be put on their computer that your website could then check for to know if they have been there before. But this should only be used if you are trying to remember if the user has been there before, not to get any kind of account information as it is highly insecure.

Otherwise, username and password is how you will need to go.
thanks for your contributions