Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Fetching MAC address of clients machine

Fetching MAC address of clients machine

Scheduled Pinned Locked Moved ASP.NET
helpquestion
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    krishnaveer
    wrote on last edited by
    #1

    Dear all, How we can fetch clients machine MAC address??? If any idea plz help Thanx

    krishna veer singh

    A L J 3 Replies Last reply
    0
    • K krishnaveer

      Dear all, How we can fetch clients machine MAC address??? If any idea plz help Thanx

      krishna veer singh

      A Offline
      A Offline
      Abhishek Sur
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • K krishnaveer

        Dear all, How we can fetch clients machine MAC address??? If any idea plz help Thanx

        krishna veer singh

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        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>
        &

        K 2 Replies Last reply
        0
        • L Lost User

          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>
          &

          K Offline
          K Offline
          krishnaveer
          wrote on last edited by
          #4

          Thanx alot.. let me try with this code..

          krishna veer singh

          1 Reply Last reply
          0
          • L Lost User

            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>
            &

            K Offline
            K Offline
            krishnaveer
            wrote on last edited by
            #5

            ActiveX code example is not working with any browser M using asp.net 2.0. Where m doing wrong??

            krishna veer singh

            1 Reply Last reply
            0
            • K krishnaveer

              Dear all, How we can fetch clients machine MAC address??? If any idea plz help Thanx

              krishna veer singh

              J Offline
              J Offline
              Jeremy Likness
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups