Fetching MAC address of clients machine
-
Dear all, How we can fetch clients machine MAC address??? If any idea plz help Thanx
krishna veer singh
-
Dear all, How we can fetch clients machine MAC address??? If any idea plz help Thanx
krishna veer singh
you mean from browser ?? No I dont think it is possible. You can only detect IP address from ServerVariables. :cool:
Abhishek Sur
My Latest Articles **Create CLR objects in SQL Server 2005 C# Uncommon Keywords Read/Write Excel using OleDB
**Don't forget to click "Good Answer" if you like to.
-
Dear all, How we can fetch clients machine MAC address??? If any idea plz help Thanx
krishna veer singh
ActiveX code example is
<script language="javascript">
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;
}
</script>The above code will work fine for IE. ASP based code example is as Copy and paste the two ASPFiles below
The first ASP file- NIC5.ASP
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>WMI Scripting HTML</title><script FOR="foo" EVENT="OnCompleted(hResult,
pErrorObject, pAsyncContext)" LANGUAGE="JScript">document.forms\[0\].txtMACAddr.value=unescape(MACAddr); document.forms\[0\].txtIPAddr.value=unescape(IPAddr); document.forms\[0\].txtDNSName.value=unescape(sDNSName); document.formbar.submit(); </script>
<script FOR="foo" EVENT="OnObjectReady(objObject,
objAsyncContext)" LANGUAGE="JScript">if(objObject.IPEnabled != null && objObject.IPEnabled !
= "undefined" && objObject.IPEnabled == true)
{if(objObject.MACAddress != null &&
objObject.MACAddress != "undefined")
MACAddr = objObject.MACAddress;if(objObject.IPEnabled && objObject.IPAddress(0) !=
null && objObject.IPAddress(0) != "undefined")
IPAddr = objObject.IPAddress(0);if(objObject.DNSHostName != null &&
objObject.DNSHostName != "undefined")
sDNSName = objObject.DNSHostName;} </script>
</head>
& -
ActiveX code example is
<script language="javascript">
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;
}
</script>The above code will work fine for IE. ASP based code example is as Copy and paste the two ASPFiles below
The first ASP file- NIC5.ASP
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>WMI Scripting HTML</title><script FOR="foo" EVENT="OnCompleted(hResult,
pErrorObject, pAsyncContext)" LANGUAGE="JScript">document.forms\[0\].txtMACAddr.value=unescape(MACAddr); document.forms\[0\].txtIPAddr.value=unescape(IPAddr); document.forms\[0\].txtDNSName.value=unescape(sDNSName); document.formbar.submit(); </script>
<script FOR="foo" EVENT="OnObjectReady(objObject,
objAsyncContext)" LANGUAGE="JScript">if(objObject.IPEnabled != null && objObject.IPEnabled !
= "undefined" && objObject.IPEnabled == true)
{if(objObject.MACAddress != null &&
objObject.MACAddress != "undefined")
MACAddr = objObject.MACAddress;if(objObject.IPEnabled && objObject.IPAddress(0) !=
null && objObject.IPAddress(0) != "undefined")
IPAddr = objObject.IPAddress(0);if(objObject.DNSHostName != null &&
objObject.DNSHostName != "undefined")
sDNSName = objObject.DNSHostName;} </script>
</head>
&Thanx alot.. let me try with this code..
krishna veer singh
-
ActiveX code example is
<script language="javascript">
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;
}
</script>The above code will work fine for IE. ASP based code example is as Copy and paste the two ASPFiles below
The first ASP file- NIC5.ASP
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>WMI Scripting HTML</title><script FOR="foo" EVENT="OnCompleted(hResult,
pErrorObject, pAsyncContext)" LANGUAGE="JScript">document.forms\[0\].txtMACAddr.value=unescape(MACAddr); document.forms\[0\].txtIPAddr.value=unescape(IPAddr); document.forms\[0\].txtDNSName.value=unescape(sDNSName); document.formbar.submit(); </script>
<script FOR="foo" EVENT="OnObjectReady(objObject,
objAsyncContext)" LANGUAGE="JScript">if(objObject.IPEnabled != null && objObject.IPEnabled !
= "undefined" && objObject.IPEnabled == true)
{if(objObject.MACAddress != null &&
objObject.MACAddress != "undefined")
MACAddr = objObject.MACAddress;if(objObject.IPEnabled && objObject.IPAddress(0) !=
null && objObject.IPAddress(0) != "undefined")
IPAddr = objObject.IPAddress(0);if(objObject.DNSHostName != null &&
objObject.DNSHostName != "undefined")
sDNSName = objObject.DNSHostName;} </script>
</head>
&ActiveX code example is not working with any browser M using asp.net 2.0. Where m doing wrong??
krishna veer singh
-
Dear all, How we can fetch clients machine MAC address??? If any idea plz help Thanx
krishna veer singh
Krisha, If you are looking at the Internet, you're out of luck. TCP/IP is higher in the stack than the MAC (layer 2) and that gets lost in the router once packets are routed out to the internet. If you are looking at an Intranet, i.e. inside your 4 walls, then you'll need something native on the server that is getting the client request that can bond to and query the network adapter for the machine. That's very low-level however as the public interfaces give you the MACS of your own adapters but you really need to integrate with the router to get the MAC of the routed packets. Somewhere in the system a router maps "MAC x with IP y" and that is where you can make the translations. What's the background of what/why you need the MAC? Jeremy
Jeremy Likness Latest Article: Whats in Your Collection? Part 1 of 3: Interfaces Blog: C#er : IMage