Is there any mechanism to identify a device uniquely (even if it is anonymous)?
To be clear, by "device" I mean the computer/slate/pc.
Windows 8.x
string HardwareId()
{
var token = Windows.System.Profile.HardwareIdentification.GetPackageSpecificToken(null);
var hardwareId = token.Id;
var dataReader = Windows.Storage.Streams.DataReader.FromBuffer(hardwareId);
var bytes = new byte[hardwareId.Length];
dataReader.ReadBytes(bytes);
return BitConverter.ToString(bytes);
}
Windows 10
You must add the Mobile and/or Desktop extension SDK.
string HardwareId()
{
var token = HardwareIdentification.GetPackageSpecificToken(null);
var hardwareId = token.Id;
var dataReader = Windows.Storage.Streams.DataReader.FromBuffer(hardwareId);
var bytes = new byte[hardwareId.Length];
dataReader.ReadBytes(bytes);
return BitConverter.ToString(bytes);
}
Could this be used as a consistent ID for the logged in user?
http://msdn.microsoft.com/en-us/library/windows/apps/windows.security.exchangeactivesyncprovisioning.easclientdeviceinformation.id.aspx
EasClientDeviceInformation.Id | id property
Returns the identifier of the local computer. The Id property represents the DeviceId using the GUID truncated from the first 16 bytes of the SHA256 hash of MachineID, User SID, and App ID where the MachineID uses the SID of the local users group. Each component of the GUID is returned in network byte order.
There doesn't seem to be a convenient way for Metro Style apps in Windows 8 to obtain a system-maintained unique identifier, like Windows Phone 7 provided with its
Microsoft.Phone.Info.DeviceExtendedProperties.GetValue( "DeviceUniqueId" )
The best solution I've found so far is to simply generate a new guid in application local storage and use that identifier to identify the computer for the current and future launches of your app.
Keep in mind that the user could delete the local storage and cause your app to forget and regenerate that value (or potentially even modify/spoof the value), so don't depend on it for any critical security purposes. Since I'm only using this technique for rough statistics and usage reporting, this is fine for my needs.
Such an ability has just been added in Windows 8 RTM: