It is possible to programmatically deactivate a license on a device via the Software Potential web services. Deactivating a license on a device allows the license to be activated on another device without the need to increase the Maximum Reactivations limit set on the license.
Deactivation does NOT remove or disable the license on the deactivated device. The license on the deactivated device will continue to be valid and the licensed application will continue to run as before as long as the license remains valid.
Deactivate a License on a Device
To programmatically deactivate a license on a device call DeactivateLicenseForDevice(deviceId, licenseId)
with both:
- The LicenseID - uniquely identifies the license to be deactivated on the device.
- The DeviceID - uniquely identifies the device to be deactivated.
To deactivate a license on a device, given the device's unique identifier (DeviceID) and the license's unique identifier (LicenseID):
static void DeactivateLicense(LicenseManagementApi api, string deviceId, string licenseId) { try { api.Execute(client => { client.DeactivateLicenseForDevice(deviceId, licenseId); }); } catch (Exception ex) // NB Excecute already handles error messages, but throws the exception on { Console.WriteLine(ex.StackTrace); } }
Device ID and Device Label
The DeviceID is generated automatically on installation of the runtime on a device. The DeviceID is used to lock licenses to devices and is submitted as part of the activation requests and stored in the Software Potential Activation Service. The DeviceID is not available via the Runtime API and so cannot be accessed by the licensed application.
In addition to the DeviceID a human readable Device Label is displayed in the SP portal pages to make it easier to identify devices on which activations have taken place. As of release 3.2.1976 of the SpAgent runtime (released 08-Jun-2015) you can set the Device Label value in code via the SetDeviceLabelPolicy method in the Sp.Agent.ProductCustomizations.cs file:
/// <summary> /// <"context "> /// <para>Context that allows you to set a custom Device Label</para> /// </param> /// Replace the contents of this method to customize the value of the DeviceLabel sent up on Activation. /// </summary> /// <param name="context"></param> static void SetDeviceLabelPolicy( IActivationDeviceLabelContext context ) { context.SetDeviceLabel("My custom label"); }
You should display the Device Label in your application so the end user can quote this when the device is to be deactivated
Activation Key and License ID
Each license has a unique 5x5 Activation Key and a (GUID-like) unique LicenseID. While the Activation Key can be used to search for the license when working with the Software Potential web portal, the License ID should be used when managing a license via the Software Potential License Management web API.
You should display the Activation Key in your application so the end user can quote this when the device is to be deactivated.
Retrieving Device and License Identifiers
When deactivating a license on a device via the ILicenseManagementWS API, it's recommend to first use the Device Label and Activation Key to retrieve the required DeviceID and LicenseID values.
To retrieve the LicenseID using the Activation Key we recommend you first call:
License GetLicenseByActivationKey (string activationKey)
The returned License object will contain the required LicenseId.
To get the DeviceId you can call the following method, passing the LicenseID in the filter:
Activation[] GetActivationsByFilter (ActivationFilter filter, ActivationRetrievalOptions retrievalOptions, ref int pageIndex)
Each Activation object returned contains a) the DeviceID (returned as StoreID property), and b) the corresponding Device Label for the device.
Comments
0 comments
Article is closed for comments.