MAC Address

Hi there, sorry for the stupid Q
Is there a way to retrieve a MAC Address from a client machine in ASP.NET
I have found a way of retrieving the MAC address for the local machine (Server) but would require it for the client.

I can get the hostname and IP no problem but would require the MAC Address, if possible

reason to see what user has "disobeyed" any rules etc.. and to make sure that you can "ban" or report them on your website. an IP address isnt enough and a MAC address is.

Thanks!


Answer this question

MAC Address

  • Mark TK

    Hi Vikram,

    what about the link where is said that this is not possible are they wrong and I did trust them Sad

  • David Seymour

    Thanks for pointing out Ralph. Oops...I guess they were correct.
    My method works only on a local machine.

    For a remote machine, the only way is to use the ARP cache - but I dont think it can be done from ASP.NET.

    If you type a ARP -a at command prompt it shows the remote hosts connected and their MAC Address. But I dont think its possible to access that data from ASP.NET

    Regards,
    Vikram

  • TGhostH

    perhaps but would like to know how to RETRIEVE a MAC Address

  • Moses Bunting

    Hi,

    This should work once you have the IP Address:

    protected string GetMACAddressByIP(string ip)
    {
    try
    {
        System.Management.ManagementObjectSearcher query= new
    System.Management.ManagementObjectSearcher("SELECT * FROM
    Win32_NetworkAdapterConfiguration");
        System.Management.ManagementObjectCollection queryCollection = query.Get();
            
        bool Found = false;

        foreach(System.Management.ManagementObject mo in queryCollection)
        {
            if(mo["IPAddress"] != null)
            {
                            
                string temp;
                temp = string.Join(".",(string[])mo["IPAddress"] );
                if(!temp.Equals(""))
                {
                    if(!ip.Equals(""))
                    {
                        if(temp.Equals(ip.Trim()))
                        {
                            Found = true;
                        }
                    
                    }
                    else
                    {
                        Found = true;
                    }    
                }    
                            
                if(Found == true)
                {
                     if(mo["macaddress"] != null)
                     {
                        if(!mo["macaddress"].Equals(""))
                        {
                            return (string)mo["macaddress"];
                        }
                     }
                }
                else
                {
                    Found = false;
                }

            }
        }

        MessageBox.Show("No Mac Address Found");
        return "";
        
    }
    catch(Exception ex)
    {
        MessageBox.Show(ex.Message);
        return "";
    }
    }

    Regards,
    Vikram



  • YoungjaeKim

    yes i was going to point this out

    I could shell it out but i dont want to have to do that as it is unprofessional.

    Ok, what about using client side scripting on the page, like vbscript or javascript

  • LiquidLithium

  • MAC Address