Overview
In the following we have assumed that if you want an automatic system, however you could choose to run the Extended ActiveX control on the server in a manual system.
Steps 1-7 (in Procedure, below) explain how to implement an automatic system via ActiveX controls & Active Server Pages. A registration form enables users to select the licensing features they want to buy. An ASP page then processes the form to generate the licence keys, which it does by calling the Sheriff Extended ActiveX control.
Demo
The demo application located in the folder "SDK\ISR" shows how to implement a simple ASP page by using the Sheriff Extended ActiveX control. RegisterForm2.htm is a sample registration form and Register2.asp is the sample ASP page. The demo also shows how to automatically generate the Reference Code and authorise the user's PC with the licence key generated by the ASP page, which is done by calling the Sheriff Internet ActiveX control (SlsLocalComNet.dll) on the user's PC.
Microsoft has released useful information about ActiveX security and best practises here.
Procedure
Step 1
SlsLocalComNet.dll must be installed and registered on the client machine. Software publishers can distribute SlsLocalComNet.dll with their software packages and install & register it as part of the installation process. Alternatively, SlsLocalComNet.dll can be downloaded from Web sites and registered on the client PC by running "Regsvr32". Note that some browsers cannot run ActiveX controls.
SheriffEx.dll must be installed and registered on the server machine.
Step 2
The software publisher sets up an HTML form that enables users to select from the the various licensing options. RegisterForm2.htm is an example of this type of registration form.
Step 3
To automatically generate the Reference Code, you need to call GetReferenceCode method from the SheriffNet ActiveX control by using VBScript or JavaScript. RegisterForm2.htm calls GetReferenceCode as soon as the page is loaded, so that the Reference Code is automatically filled up. Following is the script found in the RegisterForm2.htm.
<SCRIPT LANGUAGE="JavaScript">
function loadPage()
{
Sheriff.ProductID="9758-3050-1918-9292-6466"
var RefCode;
RefCode=Sheriff.GetReferenceCode()
if(Sheriff.Succeeded())
document.RegForm.RefCode.value=RefCode
}
</SCRIPT>
Step 4
Once the user has selected the licence options to purchase, he/she will click on the "Submit" button to submit his/her order. The contents of the form will then be transmitted to the ASP page on the server specified by the ACTION attribute in the registration form. For example, in the RegisterForm2.htm, register2.asp is specified to process the form.
Step 5
In the Register2.asp, the registration form is parsed to get the options that the user has selected together with the Reference Code
Step 6
To generate the licence key, Register2.asp calls GetLicenceKey method from the SheriffEx ActiveX control with the Reference Code and licensing options.
Step 7
Once the licence key is successfully generated, you can automatically authorise the client PC with the key. To do this, you need to call SetLicenceKey method from the SheriffNet ActiveX control that is already installed on the client PC. If you want to provide the optional "publisher data", call SetPublisherData method. Following is the script found in the Register2.asp.
<SCRIPT LANGUAGE="JavaScript">
function SetLicenceKey()
{
Sheriff.ProductID = "9758-3050-1918-9292-6466"
Sheriff.SetLicenceKey("<%=RefCode%>","<%=LicenceKey%>")
if(Sheriff.Succeeded()==true)
{
if("<%=PubData%>"!="")
Sheriff.SetPublisherData("<%=PubData%>");
}
if(Sheriff.Succeeded()==true)
{
alert("Your machine is successfully licensed");
}
else
{
var ErrorMessage;
ErrorMessage=Sheriff.GetLastErrorMessage();
alert("Error: "+ErrorMessage);
}
}
</SCRIPT>