1

We have multisite setup with two websites pointing to two domains in sites.config and we are trying to map custom membership provider to each of the domains.

Here is the configuration:

Web.config:

    <membership defaultProvider="sitecore" hashAlgorithmType="SHA1">
  <providers>
    <clear />
    <add name="sitecore" type="Sitecore.Security.SitecoreMembershipProvider, Sitecore.Kernel" realProviderName="switcher" providerWildcard="%" raiseEvents="true" />
    <add name="sql" type="System.Web.Security.SqlMembershipProvider" connectionStringName="core" applicationName="sitecore" minRequiredPasswordLength="1" minRequiredNonalphanumericCharacters="0" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" />
    <add name="custommembershipprovider1" type="Myproject.custommembershipprovider1, Myproject" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="8" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" applicationName="/" />
    <add name="custommembershipprovider2" type="Myproject.custommembershipprovider1, Myproject" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="8" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" applicationName="/" />
    <add name="switcher" type="Sitecore.Security.SwitchingMembershipProvider, Sitecore.Kernel" applicationName="sitecore" mappings="switchingProviders/membership" />
  </providers>
</membership>

Sitecore.Config:

  <switchingProviders>
<membership>
  <provider providerName="sql" storeFullNames="true" wildcard="%" domains="*" />
  <provider providerName="custommembershipprovider1" storeFullNames="false" wildcard="%" domains="Domain1"/>
  <provider providerName="custommembershipprovider2" storeFullNames="false" wildcard="%" domains="Domain2"/>
</membership>
<roleManager>
  <provider providerName="sql" storeFullNames="true" wildcard="%" domains="*" ignoredUserDomains="" allowedUserDomains="" />
</roleManager>
<profile>
  <provider providerName="sql" storeFullNames="true" wildcard="%" domains="*" ignoredDomains="" />
  <provider providerName="customprofileprovider1" storeFullNames="false" wildcard="%" domains="Domain1"/>
</profile>

Domains.Config:

<domain name="sitecore" ensureAnonymousUser="false" />

Calling authentication manager in code:

AuthenticationManager.Login(
            fullUsername, // passing "Context.Domain\Username"
            password,
            false)

When I try this the AuthenticationManager hits ValidateUser() of "custommembershipprovider1" for both the domains.

Am i missing anything here in mapping domain to specific custom membership provider?

  • That's exactly what the Switching Provider is meant to do. Cycle through all the providers to get a potential match. If you want to limit, you need something to limit on. Like each provider should be responsible for it's own domain, instead of all of them being on the sitecore domain. – Mark Cassidy Nov 8 at 9:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.