# How to tighten binding to a virtual machine

When binding a license to a virtual machine, we recommend setting the QlmLicenseBinding to EQlmUniqueSystemIdentifier2. This binding detects if the user is running on a virtual machine and binds the license to the UUID of the virtual machine.

The UUID of a virtual machine is supposed to be unique. When users clone a virtual machine, they are however presented with the option to create a clone with the same UIID as the source virtual machine. This is typically needed when the purpose of the cloning is to move the virtual machine to a new host. In an enterprise environment, having two virtual machines with the same UUID is problematic from a virtual machine management perspective.

The solution presented here is meant to protect against the use case of two VMs using the same UUID.&#x20;

The proposed solution creates a new computer unique identifier (computerID) by combining the UUID of the virtual machine with a QLM-generated unique identifier.

To achieve this, you must set the QlmLicenseBinding to EUserDefined and create the computerID at runtime.

The code below shows how to create a new unique computer identifier.

{% code overflow="wrap" %}

```csharp
private string GetComputerID ()
{
     QlmHardware hw = new QlmHardware();
     string computerID = hw.GetUniqueSystemIdentifier2();
                 
     string qlm_uuid = GetUniqueVMIdentifier();

     if (!String.IsNullOrEmpty(qlm_uuid))
     {
         computerID += "::" + qlm_uuid;
     }

     return computerID;     
}
private string GetUniqueVMIdentifier ()
{
    string qlm_uuid = string.Empty;

    QlmHardware hw = new QlmHardware ();
    if (hw.RunningOnVM())
    {
        if (lv.QlmLicenseObject.ReadCookie("qlm_uuid", 0, out qlm_uuid) == false)
        {
            qlm_uuid = Guid.NewGuid().ToString();
            bool userLevelResult;
            bool machineLevelResult;
            string errorMessage;

            lv.QlmLicenseObject.StoreCookie(qlm_uuid, "qlm_uuid", 0, out userLevelResult, out machineLevelResult, out errorMessage);
        }
    }

    return qlm_uuid;
} 
```

{% endcode %}

The code below shows how to use the LicenseValidator class to use the new computer identifier:

{% code overflow="wrap" %}

```csharp
private void VerifyLicense()
{
    bool needsActivation = false;
    string errorMsg = string.Empty;

    ELicenseBinding licenseBinding = ELicenseBinding.UserDefined;  

    if (lv.ValidateLicenseAtStartup(GetComputerID(), ref needsActivation, ref errorMsg) == false)
    {
        int exitCode = DisplayLicenseForm();

        if (exitCode == 4)
        {
            Environment.Exit(0);
        }

        if (lv.ValidateLicenseAtStartup(computerID, ref needsActivation, ref errorMsg) == false)
        {
            Environment.Exit(0);
        }
    }
}

private int DisplayLicenseForm()
{
    string errorMessage;
    if (lv.QlmLicenseObject.ValidateSettingsFile (settingsFile, out errorMessage) == false)
    {
        MessageBox.Show(this, errorMessage, "QLM", MessageBoxButtons.OK, MessageBoxIcon.Error);
        return 0; 
    }

    string args = String.Format("/settings \"{0}\" /computerID \"{1}\"", settingsFile, GetComputerID());
    
    int ret = lv.QlmLicenseObject.LaunchProcess(wizardExe, args, true, true);

    return ret;
}
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.soraco.co/docs/faq/how-to-tighten-binding-to-a-virtual-machine.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
