There are two cases to consider when your application is hosted on a virtual machine.
When you generate a trial license, you can either generate a license key that expires after a given duration or key that expires on a given date.
If a key expires on a specific date, the key will expire on a given date on any VM, even if it is cloned. This case is therefore properly handled.
If a key expires after a given duration, QLM records on the server the first time the license was activated and stores the expiry date of the license on the server in the SubscriptionExpiryDate field (you must enable the useDurationToSetExpiryDateWhenActivation property).
If the same key is reused from another cloned VM with the intent of starting over the trial, QLM will use the SubscriptionExpiryDate property on the server during the activation process and will issue a key based on that value.
Alternatively, you may want to prevent users from installing a trial on a VM. You can use the QlmHardware.RunningOnVM to detect if your application is running on a VM. If it is and the key is a trial key, you can exit your application.
For permanent licenses, you can limit the number of times a license can be activated on a given system. Note that this applies to trial / subscription licenses as well.
Whenever a license is activated on a given system, the ActivationCount value is increment by one. To limit the number of times a license can be activated on a given system, you set a Server Property called maxActivationPerSystem to the value of your choice.
For example, if you set the maxActivationPerSystem to 1 and the user tries to activate the same license on a cloned VM, the 2nd activation will fail.
You can select to enforce this property on VMs only. To do so, set the Server Property maxActivationsEnforcedOnVMsOnly to true.
In some cases, you may want to allow the user, on a case by case, to re-activate the license on the same system. To do so, you simply decrement the ActivationCount value by one.
To decrement the Activation Count, locate the license in the QLM Management Console, click Edit and update the value of the ActivationCount.
Selecting the proper computer identifier is essential for protecting your application on a virtual machine. Many of the traditional identifiers are not well suited for virtual machines. For example, a hard disk serial number could remain the same when a virtual machine is cloned.
For virtual machines, we recommend using the UUID of System Management BIOS as a unique identifier. This identifier however may not be supported in some physical machines.
We therefore recommend using 2 distinct identifiers: one for physical machines and another one for virtual machines as illustrated in the code below.
private string GetComputerID ()
string computerID = string.Empty;
QlmHardware hw = new QlmHardware();
if (hw.RunningOnVM ())
// On VMS, always use the UUID of System Management BIOS
computerID = hw.GetSMBiosUUID();
// On a physical machine, use any other identifier of your choice
// such as a ComputerName, MAC address, Volume Serial Number, etc.
computerID = hw.GetComputerName();