获取客户端的MAC地址与浏览器 [英] Getting the MAC-Address of a client with a browser

查看:201
本文介绍了获取客户端的MAC地址与浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下问题:
我有一个网络服务器。这是网络服务器路由器后面。问题是,我需要打开的服务器进行进一步的目的上的网站的客户机的MAC地址。我想已经获得通过一个ActiveX对象的MAC地址,但客户端需要安装WMI。下面是实际的code:

I have the following problem: I have a webserver. This webserver is behind a router. The problem is, I need the MAC-Address of a client that opens a website on the server for further purposes. I tried already to get the MAC-Address via an ActiveX-Object, but the client needs WMI installed. Here is the actual code:

<!DOCTYPE  HTML  PUBLIC  "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
  <head>
        <title></title>
        <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
        <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
        <script id="clientEventHandlersJS" language="javascript">

function Button1_onclick() {
  var locator = new ActiveXObject("WbemScripting.SWbemLocator");
  var service = locator.ConnectServer(".");
  var properties = service.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration");
  var e = new Enumerator (properties);
  document.write("<table border=1>");
  dispHeading();
  for (;!e.atEnd();e.moveNext ())
  {
        var p = e.item ();
        document.write("<tr>");
        document.write("<td>" + p.Caption + "</td>");
        document.write("<td>" + p.IPFilterSecurityEnabled + "</td>");
        document.write("<td>" + p.IPPortSecurityEnabled + "</td>");
        document.write("<td>" + p.IPXAddress + "</td>");
        document.write("<td>" + p.IPXEnabled + "</td>");
        document.write("<td>" + p.IPXNetworkNumber + "</td>");
        document.write("<td>" + p.MACAddress + "</td>");
        document.write("<td>" + p.WINSPrimaryServer + "</td>");
        document.write("<td>" + p.WINSSecondaryServer + "</td>");
        document.write("</tr>");
  }
  document.write("</table>");
}

function dispHeading()
{
    document.write("<thead>");
    document.write("<td>Caption</td>");
    document.write("<td>IPFilterSecurityEnabled</td>");
    document.write("<td>IPPortSecurityEnabled</td>");
    document.write("<td>IPXAddress</td>");
    document.write("<td>IPXEnabled</td>");
    document.write("<td>IPXNetworkNumber</td>");
    document.write("<td>MACAddress</td>");
    document.write("<td>WINSPrimaryServer</td>");
    document.write("<td>WINSSecondaryServer</td>");
    document.write("</thead>");
}

        </script>
  </head>
  <body>

        <INPUT id="Button1" type="button" value="Button" name="Button1" language="javascript" onclick="return Button1_onclick()">
  </body>

当你点击该按钮,它应该返回一个表,网络配置,但是,这并不为我工作。我想知道,如果有通过浏览器获取客户端的MAC地址另一种解决方案。我也不想限制对Internet Explorer中的使用。在此先感谢您的帮助。

When you click on the button, it should return a table with the network configuration, but that doesn't work for me. I'd like to know, if there is another solution for getting the MAC-Address of a client via browser. I also don't want to limit the usage on Internet Explorer. Thanks in advance for your help.

问候,
克里斯

Regards, Chris

推荐答案

看来你可以做到这一点使用Java小程序,请在postst的 https://forums.oracle.com/forums/thread.jspa?threadID=1144276 和的 http://techdetails.agwego.com/2008/02/11/37/

It seems that you can do this using a Java Applet, see postst at https://forums.oracle.com/forums/thread.jspa?threadID=1144276 and http://techdetails.agwego.com/2008/02/11/37/.

不知道,如果你需要用户同意这个安全警告或没有,我还没有尝试过。

Not sure if you need the user to agree a security warning for this or not, I have not tried it.

有可能是没有更好的办法,因为的ActiveX只能在Windows(只有IE)的工作,并没有这样的API中的任何标准的HTML或JavaScript来获得MAC地址。我不知道如果Flash可以对这项有益的,但​​我对此表示怀疑。

There is probably no better way, since ActiveX will only work on Windows (and IE only), and there is no such API to get MAC address in any standard HTML or JavaScript. I don't know if Flash can be useful for this, but I doubt that.

不过,你的理由来获得用户的MAC地址似乎有效,但我仍然认为这不是一个好主意来推断的任何信息,因为它可以欺骗/更改,并且可能无法在某些情况下正确显示。你会做的更好,如果你能拿出你的问题(不涉及抢夺MAC地址)一个更好的解决方案。

However, your reason to get user's MAC address may seem valid, but I still think it's not a good idea to deduce any information it, because it can be spoofed/changed and may not show properly in certain situations. You would do better, if you could come up with a better solution for your problem (not involving grabbing MAC addresses).

这篇关于获取客户端的MAC地址与浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆