I am trying to get the mac-address of client's machine whenever they click the button. (This is for office purpose only).
I have read multiple SO answer and in that they mentioned we can't do it using JavaScript but still am not satisfied with answer.
However I still managed to get client IP address using the below code but as the IP will be dynamic therefore I have to check for MAC address.
Code to get the client IP address .
ngOnInit(){ this.getUserIP(function(ip){ console.log(ip) }); }getUserIP(onNewIP) { // onNewIp - your listener function for new IPs //compatibility for firefox and chrome // console.log("onNewIP" , onNewIP); // (<any>window).mozRTCPeerConnection var myPeerConnection = (<any>window).RTCPeerConnection || (<any>window).mozRTCPeerConnection || (<any>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(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); }, noop); //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); }; }
Why I want to get MAC address
When the user signup in my software , later I want that user to make request from that machine only. Therefore I need the MAC address. Is this not possible?