0

I'm working on a project who have a licensing feature. It is licensed to the machine where it is installed, so, to generate a unique ID for the machine I'm using the MAC address of the network adapter.

I'm using WMI to retrieve it. This works fine in machines with only one adapter, but, when the machine has two or more adapters, I can't guarantee that I always get the same adapter from the WQL query.

I'm thinking about getting the "first adapter who has a valid MAC, ordered by index". Would it work? Or the adapter's index can change even without removing the adapter physically?

Chris Martin
  • 30,334
  • 10
  • 78
  • 137
Tyras
  • 103
  • 1
  • 7
  • What is a "valid" MAC? You you can change the MAC on a NIC, btw. See [this related question](http://stackoverflow.com/questions/5658975/c-get-processor-id). – Kenney Dec 16 '15 at 13:30
  • @Kenney There are virtual adapters in the Win32_NetworkAdapter that doesn't have a MAC (Teredo Tunneling adapter for example). Yes, I know that i can change the MAC on a NIC. It isn't the only thing I use to generate the ID. – Tyras Dec 16 '15 at 13:33
  • 1
    Ok. I don't know if it never changes, but it could. If it doesn't work out, perhaps you could ignore the index and sort the mac addresses themselves (and use all of them). – Kenney Dec 16 '15 at 13:41
  • I'm wondering about WiFi which does have a MAC and on most laptops can be disabled with a single button. And some thin laptops (Apple style) only have USB Ethernet adaptors which can _also_ go away. – MSalters Dec 16 '15 at 13:45
  • @MSalters They can be disabled, but they aren't removed from the system, so I can still query them for the MAC. (Just confirmed it) Also, the software will run in customized servers, not notebooks. – Tyras Dec 16 '15 at 13:50
  • Generally speaking, I think the best approach is to accept a license key if it matches any of the adapters on the system. For generating the key originally, let the administrator choose which adapter to use. (If only one adapter has an IP address, you could choose that one by default. But you should probably still allow the administrator to override your choice.) – Harry Johnston Dec 16 '15 at 22:52
  • It's a good approach, but there's a requirement that the users of the software (administrators included) don't know how the unique id is generated. – Tyras Dec 17 '15 at 10:58

0 Answers0