HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunitySubmit a ticketLog In
GitHubNuGetDev CommunitySubmit a ticket

Configure membership providers

Describes how to configure membership providers in Optimizely Customized Commerce 13.

Optimizely Customized Commerce has full support for the standard Optimizely membership and role providers, including Multiplex and Active Directory. Customized Commerce uses the ASP.NET membership provider model to provide secure user management for the framework. By using the provider model, you can write a custom provider to store the user information in any system and still have it function within Customized Commerce.

  1. When using custom membership, the first step is to add the custom provider to the application by adding a reference to the library containing the provider. By default, you do not need this because the "custom" provider is already referenced.

  2. Define the membership provider in the application web.config file.

    <membership defaultProvider="CMSMembershipProvider">
            <add connectionStringName="MembershipSqlConnection"
                 type="Mediachase.Commerce.Customers.Profile.Providers.CustomerSqlMembershipProvider, Mediachase.Commerce"

The above code shows the configuration of the CustomerSqlMembershipProvider. If you want to replace the provider, change the type to point to the new provider.

In Customized Commerce, you need a way to associate an authenticated user (as given by the membership provider) with a Contact/Customer. Because a property named ProviderUserKey on the MembershipUser object (as returned by a membership provider) is a unique key that identifies the user, we use that identifier.

Unfortunately, ProviderUserKey is typed as Object, and there is no generic way to convert it to something you can store and use for comparisons. To handle this, Customized Commerce has code to select different conversion methods to/from a string, depending on the type of ProviderUserKey. It currently supports Guids (used by SqlMembershipProvider), Int32 (common choice for database identifier), SID (Windows identity) and byte[] (binary data). This means that, out-of-the-box, any membership provider that uses any of the four data types for the ProviderUserKey works.

If your membership provider uses any other data type for the ProviderUserKey, implement an interface (IConvertUserKey) and register your class with the IoC container in Optimizely Customized Commerce.