views:

44

answers:

3

If I have a generic public asp.net website, I want to know who is visting my website (I know how to get that), but more importantly, I want to know what company the user is from (is this a microsoft employee viewing my website, or a Coca Cola employee viewing my site or is this person using a home computer to view my site). How can I determine the computers domain name? Hope this is making sense.

Update: At most companies, I have seen the company name included as the "Full Computer Name" or the Domain value in "Computer name, domain and workgroup settings". Thats what I am looking to access.

+2  A: 

You cannot do this with any absolute certainty - it suffers from a similar issue to getting their computer name, although you may have some success.

What you can try, is to do a reverse lookup on the IP address and take the domain part of the address (see previous link for code sample).

However, especially for smaller companies, this may just resolve to an ISP's domain, or perhaps not resolve at all. For home users it will almost certainly just be the ISP.

The other thing you could try, is to do a WHOIS on the IP address. This may give you an indication of the company; again, for smaller companies this is more likely to just be an ISP.

Rob Levine
A: 

You can use Request.ServerVariables("remote_addr") to find the ip address that is being passed to you from the client and then use it to find out where it's coming from. A word of warning though, ip addresses can be spoofed, plus you may just be getting the address of a proxy server, so these things aren't exact.

After you get the ip address you'll need to do a whois lookup to find out who it's from. You may want to look here to find a whois api.

Also you may just consider running some sort of web log analysis through webtrends or some other analysis tool to get the same information in batch form. Because all of this information is more than likely being stored in your web server logs.

mwgriffith
A: 

You cannot access computer name / domain name credentials without the user actually logging on to your public website with those credentials. If that were the case, you could access the remotely logged-on user using:

Request.ServerVariables["REMOTE_USER"]

The only way to get close to what you are asking is to use third party software. Maxmind.com is just one company that has a Geo location service. You can see that they offer an organisation field in their IP-to-City lookup.

If a user accesses your website from within a corporate network, Maxmind should have that data as part of their database, which you can then use.

Remember that the organisation refers to the IP address (netblock) owner. Therefore, should the user access your website from home, or from a mobile device, or anywhere outside the corporate network (or Maxmind has incorrect or incomplete data), then the data would be missing, misleading or flat wrong. The organisation needs to be big enough to own and register its own IP address block.

This info may also be available in Google Analytics.

Junto
well, if a user is logging in from work, and they work at Microsoft, I would guess that they can only log on using their work credentials, correct?
user279521