如何在客户端获取系统处理器ID [英] How to get system processor id in client side

查看:167
本文介绍了如何在客户端获取系统处理器ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个场景,一个系统登录用户,我需要系统处理器ID,如果系统包含多个IP,我们该如何获取.


谢谢,
shyam

我尝试过的事情:

Hi Everyone,

I have one scenario single system login user,i need system processor id and if system contains multiple IP how we can get.


Thanks,
shyam

What I have tried:

<script type="text/javascript">
        /**
 * Get the user IP throught the webkitRTCPeerConnection
 * @param onNewIP {Function} listener function to expose the IP locally
 * @return undefined
 */
        function getUserIP(onNewIP) { //  onNewIp - your listener function for new IPs
            //compatibility for firefox and chrome
            var myPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection;
            var pc = new myPeerConnection({
                iceServers: []
            }),
            noop = function () { },
            localIPs = {},
            ipRegex = /([0-9]{1,3}(\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/g,
            key;

            function iterateIP(ip) {
                if (!localIPs[ip]) onNewIP(ip);
                localIPs[ip] = true;
            }

            //create a bogus data channel
            pc.createDataChannel("");

            // create offer and set local description
            pc.createOffer().then(function (sdp) {
                sdp.sdp.split(''\n'').forEach(function (line) {
                    if (line.indexOf(''candidate'') < 0) return;
                    line.match(ipRegex).forEach(iterateIP);
                });

                pc.setLocalDescription(sdp, noop, noop);
            }).catch(function (reason) {
                // An error occurred, so handle the failure to connect
            });

            //listen for candidate events
            pc.onicecandidate = function (ice) {
                if (!ice || !ice.candidate || !ice.candidate.candidate || !ice.candidate.candidate.match(ipRegex)) return;
                ice.candidate.candidate.match(ipRegex).forEach(iterateIP);
            };
        }

        // Usage

        getUserIP(function (ip) {
            alert("Got IP! :" + ip);
        });

        function showMacAddress() {
            var obj = new ActiveXObject("WbemScripting.SWbemLocator");
            var s = obj.ConnectServer(".");
            var properties = s.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration");
            var e = new Enumerator(properties);
            var output;
            output = ''<table border="0" cellPadding="5px" cellSpacing="1px" bgColor="#CCCCCC">'';
            output = output + ''<tr bgColor="#EAEAEA"><td>Caption</td><td>MACAddress</td></tr>'';
            while (!e.atEnd()) {
                e.moveNext();
                var p = e.item();
                if (!p) continue;
                output = output + ''<tr bgColor="#FFFFFF">'';
                output = output + ''<td>'' + p.Caption; +''</td>'';
                output = output + ''<td>'' + p.MACAddress + ''</td>'';
                output = output + ''</tr>'';
            }
            output = output + ''</table>'';
            document.getElementById("box").innerHTML = output;
            alert(output);
        }

</script>



我尝试了这段代码,它可以在单系统ip地址上工作..



I tried this code,its working on single system ip adress ..

推荐答案

您不要.

在浏览器中运行的Javascript根本无法访问系统.另外,大多数系统默认情况下都关闭ProcessorID,而没有人将其打开.

MAC地址对每个系统都不是唯一的地址,因此对您不利.

在Web应用程序中,您实际上不能阻止来自多个系统的多次登录.从服务器端,您唯一可以跟踪的是登录请求来自的IP地址.即使那样,您也必须允许登录到期,因为用户可能永远不会注销系统,而只是关闭浏览器.对于您的系统,这意味着允许多次登录,可能来自不同的IP地址.

IP地址在大多数环境中也都是租用的.它们不是永久分配给计算机的,并且可以不时更改,尤其是在计算机已关闭任何时间的情况下.
You don''t.

Javascript running in a browser has no access to the system at all. Also, most systems have the ProcessorID turned off by default and nobody turns it on.

The MAC addresses will do you no good as they are not unique addresses for every system.

In a web app, you really cannot prevent multiple logins from multiple systems. The only thing you can track, from the server side, is the IP address the login request came from. Even then, you have to allow for a login to expire because a user may not ever log out of the system and just close the browser. To your system, that means allowing multiple logins, possibly from different IP addresses.

IP Addresses are also leased in most environments. They are not permanently assigned to machines and can change from time to time, especially if a machine has been shutdown for any length of time.


这篇关于如何在客户端获取系统处理器ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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