MAC address or other "unique" identifier

Hi. Is the MAC address relatively unique by computer? I’ve read some topics that this can be changed, but is that usually the case, or can you depend on this as being pretty unique for each comp?

My next question is how do you identify this with code? I was looking through the language reference a bit but didn’t know what to search for.

Follow-up question… Would this work for Windows and Mac, or just Win? If not for Mac too, what would be similar as an identifier?

Technically, the MAC address is unique to each device but that’s not always the case. Cheap components, especially, aren’t very reliable in being unique.

It’s also not a good unique identifier for use in things like serial numbers because it will change and sometimes frequently. Computers will go from WiFi to ethernet to USB modems to Bluetooth and each one has a MAC Address. I’ve had clients insist on using the MAC address as a unique identifier and it’s usually been a waste of time.

Short answer: There’s no such thing.
Long answer: The boot hard drive volume UUID is pretty reliable, but not bulletproof by any means.

We normally relay on several things. Like in our SystemInformationMBS module we have the Mac’s serial number, Windows Product Key, hard disk serial, Ethernet MAC address, CPU Product ID and others.

But that’s not foolproof either. I had an issue today where Admin vs non-admin users get different machine id’s. That’s unique, definitely, but by user. This was in Windows.

Thanks guys. I’m not looking for bulletproof, as I already have a fairly decent registration process going.

What I’m trying to do is find some identifier of the machine. I’m going to start to allow multiple users to the program on the same machine (one install, separate credential logins - would just be for colleges/universities using the app). The initial login (IT dept) will register the program with the reg code I provide and store this in their appdata and also on a server along with an identifier (thought it’d be MAC). Next student logs into the computer, but instead of asking them to register the app, the app would first connect to the MySQL server and check to see if the identifier is present. If it matches, the registration code would be copied to and saved into their appdata folder, and the 2nd and consecutive users would not have to register.

I’m just brainstorming this now and think this should work for my needs.

So would MAC address or boot hard drive volume UUID be the same for each login to the one machine? Would this be the same for Mac computers? Is there an easy code snippet for obtaining one of these identifying IDs?

On Mac, you can use the shell command diskutil info / | grep 'Volume UUID' | awk '{print $3}' to get it. On Windows, you need to use the GetVolumeInformationW or GetVolumeInformationA functions. I don’t have code handy for that, MBS might be able to help. On Linux, I don’t have a solution.

On a LAN the MAC address should be relatively unique

But if the machine happens to have more than one adapter (ethernet + wifi) you’ll need to make sure you grab the MAC address for the same one every time and gawd forbid it ever gets swapped out because of a failure :slight_smile:

But thats true for any component like the HD etc

Well, we have SystemInformationMBS module if you use our plugins:
http://www.monkeybreadsoftware.net/system-systeminformationmbs.shtml

For Hard Disk Serial on Windows you can use WMI, not the GetVolumeInformation functions (which give logical volume ID).

It’s debating which you prefer. I prefer the volume UUID over the hard drive serial, as multiple partitions on the same drive will return different identifiers. A hard drive with two operating systems could be argued to be considered two computers, despite being a single physical box.

Not saying one is inherently better than the other, they serve different purposes.

[quote=89603:@Ryan Hartz]So would MAC address or boot hard drive volume UUID be the same for each login to the one machine? Would this be the same for Mac computers? Is there an easy code snippet for obtaining one of these identifying IDs?
[/quote]

MAC address can be faked, so you are not sure it will stay the same. You may want to go for volume UUID.

Get the SSID of the computer.

[code]Soft Declare Function LookupAccountName Lib “advapi32.dll” Alias “LookupAccountNameA” _
(IpSystemName As cString, _
IpAccountName As cString, _
pSid As Ptr, _
ByRef cbSid As Integer, _
ReferencedDomainName As ptr, _
ByRef cbReferencedDomainName As Integer, _
ByRef peUse As Integer) As Integer

soft declare function ConvertSidToStringSid lib “advapi32.dll” alias “ConvertSidToStringSidA” _
(psid as Ptr, byref ssid as ptr) as boolean

Dim pSia As Integer
Dim pSiaByte As new MemoryBlock(5)
Dim pSid As new MemoryBlock(512)

dim thecbSid as Integer
dim thecbRDN as Integer
dim thepeUse as Integer = 1
Dim pDomain As new memoryblock(512)
Dim IReturn As Integer

dim strNTDomain, strNTAccount as string

strNTDomain = “”
strNTAccount= “Administrator”

IReturn = LookupAccountName(strNTDomain, strNTAccount,pSid, thecbSid, pDomain, thecbRDN, thepeUse)

pSid= new MemoryBlock(thecbSid)
pDomain= new MemoryBlock(thecbRDN)

IReturn = LookupAccountName(strNTDomain, strNTAccount,pSid, thecbSid, pDomain, thecbRDN, thepeUse)

dim sSid as Ptr
dim strSid as string
dim mb as MemoryBlock

call ConvertSidToStringSid(psid, ssid)
mb= ssid
strSid= mb.Cstring(0)[/code]

In my above code change the strNTAccount to:

strNTAccount= System.EnvironmentVariable("Computername")

Now you will get the SID of the computer.

I run into duplicate MAC addresses on the LAN (good luck they are unique on the their given LAN segment). We tend to get duplicates on cheap hardware.

then when you add VMware on that machine you will get at least 1 if not 3 more MAC addresses for the computer (not counting the virtual machines). My old mac had over 8 MAC addresses for itself.

I should have said that better - they should be relatively unique on their LAN segment other wide you get piles of network issues
Which is, I’m guessing, what you’re griping about :stuck_out_tongue:

[quote=89638:@Norman Palardy]I should have said that better - they should be relatively unique on their LAN segment other wide you get piles of network issues
Which is, I’m guessing, what you’re griping about :P[/quote]

yeah… griping? no more like whining like a child with a skinned knee. Having duplicates makes a wonderful time on the network. And it makes all of our lives soo wonderful. /sarcasm

ok, no more whining, more coding…

Great discussion. Thanks to everyone for chiming in.

It sounds like there’s no one true, unique identifier like people’s fingerprints or SS numbers for machines.

Let me ask this… Since my desire for this is to “copy over” the initial registration of user A so user B, logging into the same computer but with his own credentials, doesn’t need to register since user A already did, is there a way to copy over the database file from user A’s appdata folder to user B’s? Keeping in mind that the db was empty prior to registering, and a db containing data = registered

Can you copy a file from startup on one credential to another?

[quote=89589:@Thom McGrath]Short answer: There’s no such thing.
Long answer: The boot hard drive volume UUID is pretty reliable, but not bulletproof by any means.[/quote]
I concur with Thom, in the past we have several issues with MAC addresses, where as so far touch wood we’ve not had any by using the HDD UUID or creation date. On OS X, you can get the machine serial number, but it is possible for the serial number to be lost.