It is possible to programmatically disable a license via the Software Potential web services. Disabling a license prevents the license from being activated on any device until such time as the license is re-enabled. This will disable all activation requests, including renewal requests for subscription licenses.
Disabling a license does NOT remove or disable the license on devices on which it has already been activated. A license file installed on device prior to the license being disabled will continue to be valid and the licensed application will continue to run as before as long as the license file remains valid e.g. does not expire or require renewal.
Disable a License
To programmatically disable a license you will need either the license Activation Key or LicenseID, either of which uniquely identifies the license to be deactivated on the device.
- The Activation Key - this is the 5x5 key used to activate the license
- The LicenseID - this is a unique license identifier that should be used in preference to the Activation Key where possible.
Where possible the License ID property should be used in preference to the Activation Key when querying Software Potential for license data. The Activation Key is an asset that allows activation of a license by anyone that posses the key and so it should be used sparingly.
To disable a a license, you will need to:
- First retrieve the license from Software Potential service using either the Activation Key or LicenseID
- Set the license Enabled property to FALSE
- Update the license in Software Potential service
This sequence is shown in the following code snippet using the License Id:
static void DisableLicense(LicenseManagementApi api, string licenseId) { try { api.Execute(client => { License license = client.GetLicenseById( licenseId ); //Alternatively you can use the Activation Key if LicenseId is not available //License license = client.GetLicenseByActivationKey( activationKey ); license.LicenseInfo.Enabled = false; client.UpdateLicense( license, false ); }); } catch (Exception ex) // NB: Execute already handles error messages, but throws the exception on { Console.WriteLine(ex.StackTrace); return null; } }
When disabling a license it is not necessary to reissue the license, unless you plan to update other license properties that necessitate reissuing the license. Therefore, when only disabling a license, set the andReissue flag to False when calling UpdateLicense() as is shown in the snippet above.
License Id
The unique license identifier LicenseID is a property of the License object that can be retrieved by querying Software Potential using any of the following methods
- GetLicenseByActivationKey
- GetLicensesByFilter
When storing license data in an external systems, such as a CRM / ERP systems for example it is recommended that the LicenseID be stored as a criticial license property to be used subsequently with the Software Potential web services API.
Comments
0 comments
Article is closed for comments.