Please find the below additional information on custom licensing model.
If a solution needs custom licensing , it will need to implement its own licensing policy, and inheriting from LicensingPolicy. A solution will have to override ConstructLicensingPolicyFromDetails in order to handle additional styles which must be defined to correspond with the new custom licensing. Call into the base to handle the default licensing policy styles.
protected override Altiris.NS.Licensing.ILicensingPolicy ConstructLicensingPolicyFromDetails(Guid licensingPolicyId, string styleName, System.Xml.XPath.XPathNavigator licensingPolicyLoc)
{
if (styleName == "CustomInventoryBasedForInvSol")
{
return new LicensingPolicyInventorySolution(licensingPolicyId, licensingPolicyLoc);
}
else
{
return base.ConstructLicensingPolicyFromDetails(licensingPolicyId, styleName, licensingPolicyLoc);
}
}
When a license check is required, the standard method is to obtain the instance of the licensing policy using LicensingPolicy.GetInstance(licensingPolicyGuid, solutionGuid) - the solutionGuid is needed so that when the licensing policy isn't currently cached we don't have to load up all the licensing policys for all products trying to find the one.
Having acquired the licensing policy, the status should be checked, to ensure it is not either invalid or expired. The status may return either OK or Exceeded, which are both 'valid' states, the later being an indicator that the license has had its count reduced recently and so the current list of license uses exceeds the limit.
The prefered model for checking licenses requires that you first filter the list of resources down to those which should have a license. The licensing policy does not provide a mechanism to do this, not even on the derived licensing policy types.
Once the resources have been filtered as such, licensingPolicy.RequestLicense should be called for each resource. If a license has already been assigned to the requested resource, this function does nothing. If not and there are available licenses, the licenses in use will be updated (asynchronously) to correct the fact that the requested resource does not yet have a license. If there are no licenses available, an exception will be thrown.
ILicensingPolicy policy = LicensingPolicy.GetInstance(licensingPolicyGuid, solutionGuid);
if (policy == null)
{
// Handle the license not installed case
}
if (policy.Status == LicensePolicyStatus.Ok || policy.Status == LicensePolicyStatus.Exceeded)
{
try
{
// This will give a license use to this resource if one has not already been given and there are still license uses available.
policy.RequestLicense(resourceGuid);
}
catch (LicenseExceededException)
{
// Handle the license exceeded case for the requested resource.
}
}
else
{
// Handle the license expired or invalid case.
}
When displaying a page related to a resource it might be useful to display whether that resource is currently licensed. The IsInUseLicense method provides a mechanism for performing this check.
ILicensingPolicy policy = LicensingPolicy.GetInstance(licensingPolicyGuid, solutionGuid);
if (!policy.IsInUseLicense(resourceGuid))
{
// Report that the specified resource is currently not using a license.
}
else
{
// Report that the specified resource is currently using a license.
}
Please make sure that which type of licensing you required because there are 3 types of licensing 1. Server Based 2. Inventory Based and 3. Agent Based.
Please refer the below links for the more detail.
- http://ali-mydev.altiris.com/Wiki/default.aspx/Altiris.NSCore/LicensingIntegration.html
- http://ali-mydev.altiris.com/Wiki/default.aspx/Altiris.NSCore/LicensingHierarchy.html
- http://ali-mydev.altiris.com/Wiki/default.aspx/Altiris.NSCore/Licensing%20Refactor.html