среда, 29 декабря 2010 г.

License Shop will be released soon

We are going to release new part of the Manco .NET Licensing System soon. We call it “License Shop”. This is web-based (Silverlight) tools for complete customer and license management. Using it you can issue licenses and keys outside your office just using any Silverlight-ready PC. You even can setup a bunch of sale persons around the world who will do it for you 24x7 just using single “License Shop” license. Just manage your sale persons to use “License Shop” on 1 in a time basis. We don’t allow concurrent using of the single license. But “License Shop” is not bound to the particular PC (it is bound to the AWS installation), so you can use single license anytime anywhere on 1 license - 1 concurrent connection basis.
Starting from version 6.0.1.0 of our licensing system Activation Web Service license will include 1 free license for “License Shop”. So you can start your web-based licensing experience without any extra charge. All customers who bought version 6.0 or have active subscription will get upgrade to version 6.0.1.0 for free.

Here are few “License Shop” screenshots:



пятница, 10 декабря 2010 г.

How to debug custom "User Data" edit control.

Sometimes user data or product edition are included to the Unlock Key has complex format. For example, user data can contain specification of the product edition and number of the concurrent sessions allowed for ASP.NET application. In this case using of the simple text box becomes a quite problematic for sales persons. They should remember format of the user data and enter something like “PE043” every time when customer buy Professional Edition with 43 concurrent sessions allowed.

License Manager allows you creation and using of the custom controls to simplify editing of the complex user data. The process of creation of the custom edit control is described in our product documentation. Mostly those controls are quite simple and work without any problems. But sometimes it is necessary to debug functionality of the custom edit control. You can do it using Visual Studio.

Open your solution in the VS2010. Then run License Manager with your control in use. In the VS2010 main menu go to the Debug->Attach to Process:

















In the “Attach to Process” dialog select “Manco.Licensing.LicenseManager” process and click “Attach” button:



















After that you will be able to debug your control.

Don’t forget to replace DLL near the License Manager every time you change something in your control.

воскресенье, 14 ноября 2010 г.

64-bit OS and License Manager database.

In the present days many people are moving to the 64-bit OS and put old versions of the License Manager to this platform. There are not any problems if MS SQL database is in use, but when the License Manager database is MS Access you run into the difficulties. If you run our application on 64-bit platform with MS Access database you get ‘Microsoft.Jet.OLEDB.4.0 provider is not registered on the local machine’ exception.

There is not 64-bit version of Jet and Microsoft has no plans to create a 64-bit version of Jet. So you can’t use License Manager with MS Access database on 64-bit platform. Fortunately our product supports using of the MS SQL database, either Express version or fully functional server. You can find instructions on how to setup License Manager to use MS SQL here: www.mancosoftware.com/licensing/faq.htm

It is not difficult to get License Manager using the MS SQL, but you definitely would like to move your existing data from MS Access database to MS SQL as well. It was a bit problematic before we release version 6.0 of our software.  Now there is a trick which can help you with your old data. There is a part of the version 6.0 which is called Database Manager. Using this application you can copy all data from your MS Access database to the MS SQL Express database even on 64-bit OS. For copy operation Database Manager supports all versions of database starting from 3.2. So you can use it to move your existing data to the new database. This application is free to use. You can download it from our official site at the http://www.mancosoftware.com/licensing/download.htm. Below you can find extraction from the version 6.0 documentation which describes how the Database Manager can be used to copy data from MS Access to MS SQL Express.
Using of the Database Manager

Database Manager is the application which install new or upgrade existing database, and allows copy licensing data from one database to another. Current version of the Database Manager supports MS SQL Server and MS SQL Express for all operations and MS Access as data source for copy operation. Support of the MS Access database makes possible upgrade of your database from any version starting from 3.2 to current version.

There are several scenarios when you need to use Database Manager, but there is one step, which is common for all these scenarios. Before you can perform any operation you should create description of the database connection.






















Click "New"  toolbar button. Enter name of the database connection (can be any) and select database type. You can simple enter connection string in the correspondent column, or click "..." button in the edit mode and edit connection string using database connection dialog:

















You always can test your database connection by clicking the “Test” button. Click “OK” to finish edition of the connection string.






















1. All versions of the Manco .NET Licensing System starting from 3.2 and up to the 5.0 were provided with both MS Access and MS SQL Express database files. The MS SQL Express database file is located at the same place with MS Access one. Create database connections for both: MS Access and MS SQL Express databases:






















2. Switch to the “Copy data” tab.
3. Select your Access database as data source.
4. Select your MS SQL Express database as destination.
5. Find “Roles”, “UserName” and “UsersInRoles” databases.
6. Check checkboxes in the “Clear destination” column for these 3 tables.



















7. Click "Copy" button to copy data from the MS Access database to the MS SQL Express database. Data from the MS Access database will be copied to the MS SQL Express database.

воскресенье, 24 октября 2010 г.

Protect ASP.NET application using name of the domain specified in the HTTP request.

Recently I’ve answered several times the question about protection of the ASP.NET application using name of the domain specified in the HTTP request. Since this licensing schema isn’t described in our 200-pages documentation yet I’ve decided to describe it in my blog. I suppose that you've read already “Quick start using ‘Unlock Key’ licensing schema” and “Protect ASP.NET application using ‘Unlock Key with Activation’ licensing schema” topics in our product documentation, so I will describe only things are specific for this licensing schema.
The first major difference is the way how you deliver licensing information to the customer. In this case you provide customer with license file instead of Unlock Key.
The next difference between simple “Unlock Key” and “HTTP request domain” schemas is a number of the license types which are necessary to fully implement schema. The “Unlock Key” requires just 1 license type, the “HTTP request domain” require 2 license types:

The “Evaluation” license type is intended to provide your customers with trial version of your product. It could locks like the following:



Expiration Days – this rule sets number of days during which your product will work in evaluation mode. This license rule can be used to create time-limited evaluation licenses. When someone attempts use licensed product after given number of days it will give “Your license has been expired” exception.
Is Evaluation – this rule indicates, that license is in evaluation mode. Allows you limit some functionality in your product using evaluation status of license.
You have to create only one license file of this type. You even can distribute this license file with your application.
The “Deployment” license type is intended to provide your customers with fully functional version of your product.  We don’t include any license rule to this license type. It will use ability of the protection library validate license using custom values:


We added 1 custom value “AllowedDomains” into our license type. This custom value will contain comma-separated list of the HTTP domains are allowed.
Protection library can compare custom value with one is available in your application as strings (by default) or use specific class class-comparer for this purposes. This class must implement IComparer<string> (IComparer(of String)) interface. Since we suppose that “AllowedDomains” custom value can contain list of the domains, then we should create own class-comparer which will walk through the list.
Add new RequestDomainComparer class into your project:
[C#]
/// <summary>
/// Compare Domain Name from the HTTP request.
/// </summary>
public class RequestDomainComparer : IComparer<string>
{
       private Manco.Licensing.License license;

       /// <summary>
       /// Creates instance of the RequestDomainComparer class.
       /// </summary>
       /// <param name="license">License object.</param>
       public RequestDomainComparer(Manco.Licensing.License license)
       {
             this.license = license;
       }
            
       /// <summary>
       /// Compare value set from application with value from
       /// the license file.
       /// </summary>
       /// <param name="valueFromApplication">Value set from application:
       /// domain name from the HTTP request.</param>
       /// <param name="customValueFromLicenseFile">Custom value set in
       /// the license file.</param>
       /// <returns>0 if domain rom HTTP request is in the list
       /// of the allowed domains. -1 otherwise.</returns>
       public int Compare(
              string valueFromApplication,
              string customValueFromLicenseFile)
       {
              if (license.IsEvaluation)
              {
                    // During evaluation time we
                    // allow only localhost domain.
                    return valueFromApplication
                           .Trim()
                           .ToLowerInvariant()
                           .CompareTo("localhost");
              }
              else
              {
                    int retVal = -1;
                    string domainFromRequest = valueFromApplication
                           .Trim()
                           .ToLowerInvariant();

                    if (domainFromRequest == "localhost")
                    {
                           // "localhost" domain name is always allowed.
                           retVal = 0;
                    }
                    else
                    {
                           // We suppose that custom value in the
                           // license file can contain list of
                           // the domains separated by comma.
                           string[] domainList =
                                  customValueFromLicenseFile.Split(',');
                           foreach (string allowedDomain in domainList)
                           {
                                  if (allowedDomain
                                         .Trim()
                                         .ToLowerInvariant()
                                         == domainFromRequest)
                                  {
                                         // We found allowed domain.
                                         // Comparision should return 0.
                                         retVal = 0;
                                         break;
                                  }
                           }
                    }

                    return retVal;
              }
       }
}

[VB.NET]
''' <summary>
''' Compare Domain Name from the HTTP request.
''' </summary>
Public Class RequestDomainComparer
       Implements IComparer(Of String)

       Private license As Manco.Licensing.License

       ''' <summary>
       ''' Creates instance of the RequestDomainComparer class.
       ''' </summary>
       ''' <param name="license">License object.</param>
       Public Sub New(ByVal license As Manco.Licensing.License)
             Me.license = license
       End Sub

       ''' <summary>
       ''' Compare value set from application with value from
       ''' the license file.
       ''' </summary>
       ''' <param name="valueFromApplication">Value set from
       ''' application: domain name from the HTTP request.</param>
       ''' <param name="customValueFromLicenseFile">Custom value set
       ''' in the license file.</param>
       ''' <returns>0 if domain rom HTTP request is in the list of
       ''' the allowed domains. -1 otherwise.</returns>
       Public Function Compare( _
         ByVal valueFromApplication As String, _
         ByVal customValueFromLicenseFile As String) _
         As Integer Implements IComparer(Of String).Compare

             If license.IsEvaluation Then
                    ' During evaluation time we allow
                    ' only localhost domain.
                    Return valueFromApplication _
                    .Trim() _
                    .ToLowerInvariant() _
                    .CompareTo("localhost")
             Else
                    Dim retVal As Integer = -1
                    Dim domainFromRequest As String = _
                    valueFromApplication _
                    .Trim() _
                    .ToLowerInvariant()

                    If domainFromRequest = "localhost" Then
                           ' "localhost" domain name is always allowed.
                           retVal = 0
                    Else
                           ' We suppose that custom value in the
                           ' license file can contain list of
                           ' the domains separated by comma.
                           Dim domainList() As String = _
                            customValueFromLicenseFile.Split(",")
                           For Each allowedDomain As String In domainList
                            If allowedDomain _
                             .Trim() _
                             .ToLowerInvariant() _
                             = domainFromRequest Then
                             ' We found allowed domain.
                             ' Comparision should return 0.
                             retVal = 0
                             Exit For
                            End If
                           Next
                    End If

                    Return retVal
             End If
       End Function
End Class

You should extend your protected class (class which implements “ILicenseKeyProvider” interface and contains static license object) with comparer static (shared) variable and new method which will pass name of the domain to compare from your application to the license object:

[C#]
[LicenseProviderAttribute(typeof(Manco.Licensing.LicenseProvider))]
public class MyAppLicense : ILicenseKeyProvider
{
       /// <summary>
       /// License object
       /// </summary>
       private static Manco.Licensing.License license = null;

       /// <summary>
       /// Comparer which will be used to validate
       /// domain in the HTTP request.
       /// </summary>
       private static RequestDomainComparer comparer = null;

       /// <summary>
       /// Constructor
       /// </summary>
       public MyAppLicense()
       {
              if (license == null)
              {
                    try
                    {
                           license =
                                  (Manco.Licensing.License)LicenseManager
                                  .Validate(typeof(MyAppLicense), this);
                           license.CallingAssembly =
                                  this.GetType().Assembly;
                           license.LicensedAssembly =
                                  this.GetType().Assembly;

                           comparer = new RequestDomainComparer(license);
                    }
                    catch (FileNotFoundException ex)
                           {
                           // License file not found
                           throw
                           new Exception(
                           String.Format("License file was not found!",
                           ex.FileName));
                    }
              }
       }


       /// <summary>
       /// Specify name of the custom value which
       /// will be used to get list of the
       /// allowed domains and set value to
       /// search in list (domain name from
       /// the HTTP request).
       /// </summary>
       /// <param name="name">Name of the custom value
       /// which will be used to get list of the allowed domains.</param>
       /// <param name="value">Domain name from the HTTP request.</param>
       public void SetCustomValueToValidate(string name, string value)
       {
             license.AddCustomValueToValidate(name, value, comparer);
       }
      
      
}

[VB.NET]
<LicenseProvider(GetType(Manco.Licensing.LicenseProvider))> _
Public Class MyAppLicense
       Implements ILicenseKeyProvider

       ''' <summary>
       ''' License object
       ''' </summary>
       Private Shared license As Manco.Licensing.License = Nothing

       ''' <summary>
       ''' Comparer which will be used to validate
       ''' domain in the HTTP request.
       ''' </summary>
       Private Shared comparer As RequestDomainComparer = Nothing

       ''' <summary>
       ''' Constructor
       ''' </summary>
       Public Sub New()
             If license Is Nothing Then
                    Try
                           license = _
                           LicenseManager.Validate(GetType(MyAppLicense), _
                           Me)
                           license.CallingAssembly = _
                           System.Reflection.Assembly.GetCallingAssembly()
                           license.LicensedAssembly = _
                           Me.GetType().Assembly

                           comparer = New RequestDomainComparer(license)
                    Catch ex As IO.FileNotFoundException
                           ' License file not found
                           Throw _
                           New Exception( _
                           String.Format("License file was not found!", _
                           ex.FileName))
                    End Try
             End If
       End Sub

      

       ''' <summary>
       ''' Specify name of the custom value
       ''' which will be used to get list of the
       ''' allowed domains and set value to
       ''' search in list (domain name from
       ''' the HTTP request).
       ''' </summary>
       ''' <param name="name">Name of the custom value
       ''' which will be used to get list of the allowed domains.</param>
       ''' <param name="value">Domain name from the HTTP request.</param>
       Public Sub SetCustomValueToValidate( _
       ByVal name As String, _
       ByVal value As String)
             license.AddCustomValueToValidate(name, value, comparer)
       End Sub

      

End Class

Depends on your needs you can validate license on per-session or on per-page basis. The validation code could looks like the following:


[C#]
string hostName = HttpContext.Current.Request.Url.DnsSafeHost;
m_oLicense.SetCustomValueToValidate("AllowedDomains", hostName);

// Check that license is valid and not expired.
if (m_oLicense.IsExpired || !m_oLicense.IsValid)
{
       // If license have been expired or it is not valid
       // then we shouldn't allow session start.
       // Throw exception.
       throw new Exception("Illegal use of this application: no valid License found");
}

[VB.NET]
Dim hostName As String = HttpContext.Current.Request.Url.DnsSafeHost
m_oLicense.SetCustomValueToValidate("AllowedDomains", hostName)

' Check that license is valid and not expired.
If m_oLicense.IsExpired Or Not m_oLicense.IsValid Then
       ' If license have been expired or it is not valid
       ' then we shouldn't allow session start.
       ' Throw exception.
       Throw New Exception("Illegal use of this application: no valid License found")
End If

When you create deployment licenses for your customers you should specify list of the HTTP domains are allowed in the request URL. For example: 




You can find sample solutions which implements this licensing schema on our official site at the http://www.mancosoftware.com/licensing/download.htm