It seems impossible to use JS to obtain the IP address and MAC of the IE client.

Source: Internet
Author: User

In a B/S system, we often need to obtain some information about the client, such as IP and MAC, for identity authentication. In ASP. NET, it is easy to get the MAC address of the server, but it is really easy to get the MAC address of the client. The common practice is to call Win32API or directly call the nbtstat command, there are a lot of problems with this, and the other method is to directly use the client script. Here we use Javascript. The advantage of this is that it does not need to be processed by the server, but can be obtained by the client itself, it is passed to the server, and the speed and reliability are better than those obtained on the server.
The specific implementation of html and javascript is as follows:

<HTML> <HEAD> <TITLE> WMI Scripting HTML </TITLE> <META http-equiv = Content-Type content = "text/html; charset = gb2312 "> <META content =" MSHTML 6.00.2800.1106 "name = GENERATOR> </HEAD> <BODY> <OBJECT id = locator classid = CLSID: export VIEWASTEXT> </OBJECT> <OBJECT id = foo classid = CLSID: 75718C9A-F029-11d1-A1AC-00C04FB6C223> </OBJECT> </BODY> </HTML>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
The key is to use two ActiveX:

<OBJECT id = locator classid = CLSID: 76A64158-CB41-11D1-8B02-00600806D9B6 VIEWASTEXT> </OBJECT>
<OBJECT id = foo classid = CLSID: 75718C9A-F029-11d1-A1AC-00C04FB6C223> </OBJECT>

However, these two ActiveX methods are provided by the system and do not need to be downloaded or registered.

The next job is to use scripts to interact with ActiveX. The script can be js or Vbs. I personally like to use js.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.