Custom password calculation

If you want to calculate user passwords in your own way, follow this procedure. You can find more information in Customizing providers.

  1. Open your Kentico solution in Visual Studio.

  2. Create a new Class Library project in the Kentico solution (or reuse an existing custom project).

  3. Add references to the required Kentico libraries (DLLs) for the new project.

  4. Reference the custom project from the Kentico web project (CMSApp or CMS).

  5. Edit the project’s AssemblyInfo.cs file (in the Properties folder).

  6. Add the AssemblyDiscoverable assembly attribute:

    
    
    
     using CMS;
    
     [assembly:AssemblyDiscoverable]
    
    
     
  7. Create a new class within the custom project.

  8. Set the class to inherit from the UserInfoProvider class.

  9. Override the GetPasswordHashInternal method.

  10. Add the RegisterCustomProvider assembly attribute above the class declaration to register the provider.

    
    
    
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    
    using CMS;
    using CMS.Helpers;
    using CMS.Membership;
    
    // Registers the custom provider
    [assembly: RegisterCustomProvider(typeof(MyUserInfoProvider))]
    
    /// <summary>
    /// Customized UserInfoProvider for password calculation.
    /// </summary>
    public class MyUserInfoProvider : UserInfoProvider
    {
        protected override string GetPasswordHashInternal(string password, string passwordFormat, string salt)
        {
            return SecurityHelper.GetSHA1Hash(password + "CustomSalt");
        }
    }
    
    
    
  11. If you are utilizing the MVC development model, also deploy the custom project to your separate MVC application.

The system now uses the customized provider (MyUserInfoProvider) instead of the default one.