Click here to Skip to main content
15,899,754 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All
I am trying to get unique Id of client machine but firewall of network not allowing me to get that I have tried for IP,MACID,Processor ID and also Mother Board ID but all are giving me server specific value of network not client machine.
Please let me know if any one idea for same.

using following code
C#
private void UpdateOnlineUsers()
 {

     int userId = Convert.ToInt32(Session["userId"].ToString());
     //string clientIp = (Request.ServerVariables["HTTP_X_FORWARDED_FOR"] ?? Request.ServerVariables["REMOTE_ADDR"]).Split(',')[0].Trim();
     string clientIp = string.Concat(GetMaccID(), cpuId());
     user.UpdateOnlineUsers(userId, clientIp, false);
 }
 //Return a hardware identifier
 private static string identifier(string wmiClass, string wmiProperty)
 {
     string result = "";
     System.Management.ManagementClass mc = new System.Management.ManagementClass(wmiClass);
     System.Management.ManagementObjectCollection moc = mc.GetInstances();
     foreach (System.Management.ManagementObject mo in moc)
     {
         //Only get the first one
         if (result == "")
         {
             try
             {
                 result = mo[wmiProperty].ToString();
                 break;
             }
             catch
             {
             }
         }
     }
     return result;
 }
 private static string cpuId()
 {
     //Uses first CPU identifier available in order of preference
     //Don't get all identifiers, as it is very time consuming
     string retVal = identifier("Win32_Processor", "UniqueId");
     if (retVal == "") //If no UniqueID, use ProcessorID
     {
         retVal = identifier("Win32_Processor", "ProcessorId");
         if (retVal == "") //If no ProcessorId, use Name
         {
             retVal = identifier("Win32_Processor", "Name");
             if (retVal == "") //If no Name, use Manufacturer
             {
                 retVal = identifier("Win32_Processor", "Manufacturer");
             }
             //Add clock speed for extra security
             retVal += identifier("Win32_Processor", "MaxClockSpeed");
         }
     }
     return retVal;
 }
 //Motherboard ID
 private static string baseId()
 {
     return identifier("Win32_BaseBoard", "Model")
     + identifier("Win32_BaseBoard", "Manufacturer")
     + identifier("Win32_BaseBoard", "Name")
     + identifier("Win32_BaseBoard", "SerialNumber");
 }
 private string GetMaccID()
 {
     string macID = string.Empty;
     foreach (System.Net.NetworkInformation.NetworkInterface nic in System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces())
     {

         if (nic.OperationalStatus == System.Net.NetworkInformation.OperationalStatus.Up && (!nic.Description.Contains("Virtual") && !nic.Description.Contains("Pseudo")))
         {
             if (nic.GetPhysicalAddress().ToString() != "")
             {
                 macID = nic.GetPhysicalAddress().ToString();
             }
         }
     }
     return macID;
 }

Please help me out
Posted
Updated 19-May-13 23:50pm
v3

1 solution

I wrote an article about something similar that might help you along:

Finger Print Class[^]
 
Share this answer
 
Comments
Sachin Kakade 20-May-13 6:11am    
Hi Johnny,
Thanks for your reply but not worked because of firewall settings.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900