How to get Client Machine's Mac Address in a Web application

前端 未结 3 630
后悔当初
后悔当初 2020-11-29 08:57

I have to get Mac Address of client\'s PC where my website is running. So how to get Mac Address of client\'s machine (not of the Server\'s Mac Address where website is host

相关标签:
3条回答
  • 2020-11-29 09:18

    I have scenario where some user are allowed from some fixed PC (for which MAC address entered by admin will match with system from where user try to logged in) , he/she will not able to logged in from other than those PC

    To achieve the above the right way, you should be relying on Client certificates to perform the authentication. If a valid client certificate is not presented then the request will be denied.

    You can find more information on Securing a website using client certificates @ http://support.microsoft.com/kb/315588

    If the users are in internal network, preferred way to authenticate them is using the Integrated windows authentication as described http://support.microsoft.com/kb/323176 and authorization will be based on a Access control list

    0 讨论(0)
  • 2020-11-29 09:18

    Sounds like this is an internal network.

    Another method is that by using mac address the dhcp server can assign particular ip ranges. you can then check for that ip range in your server code. There is not a way to get mac address in javascript, but you can get the ip easily. Also perhaps your dhcp server can publish mac address ip address tables for your web server to use via an api or something - not sure on that but may be worth looking into.

    0 讨论(0)
  • 2020-11-29 09:23

    The only way to achieve this is by using an applet or plugin which could for example be programmed in java (although java itself might not allow it according to Getting MAC address on a web page using a Java applet ), as javascript will naturally not disclose this kind of information. Lastly you could also find this information from the server side if it's on an internal network as is often done with semi-private wifi network landing pages.

    Based on the comments below: As it's an internal network you can retrieve the mac address as follows on the asp.net side. You execute the following command arp -a which will return you a list of all ip addresses with associated mac addresses. Next using something along the lines of

    Request.Servervariables("REMOTE_ADDR")
    

    you should be able to find the users ip address which you can next match with the data you retrieved from the arp command and voila, you have your mac address for the current user.

    0 讨论(0)
提交回复
热议问题