EPiServer failed to initialise after a membership/role provider became unavailable

Vote:
 

We have a number of role/membership providers for accessing our EPiServer website. One of these is an Active Directory provider that connects to an internal AD server. Recently, this server became unavailable for a period of time. A scheduled recycle of the application pool caused the website to restart, but initialization failed due to the unavailability of the AD server, and subsequently the whole website was unavailable until the AD server was back online.

Here's an extract from the error that was thrown during initialization

System.Configuration.Provider.ProviderException: Unable to establish secure connection with the server ---> System.Runtime.InteropServices.COMException: The server is not operational.

   at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail)
   at System.DirectoryServices.DirectoryEntry.Bind()
   at System.DirectoryServices.DirectoryEntry.RefreshCache()
   at System.Web.Security.DirectoryInformation..ctor(String adspath, NetworkCredential credentials, String connProtection, Int32 clientSearchTimeout, Int32 serverSearchTimeout, Boolean enablePasswordReset)
   --- End of inner exception stack trace ---
   at System.Web.Security.DirectoryInformation..ctor(String adspath, NetworkCredential credentials, String connProtection, Int32 clientSearchTimeout, Int32 serverSearchTimeout, Boolean enablePasswordReset)
   at System.Web.Security.ActiveDirectoryMembershipProvider.Initialize(String name, NameValueCollection config)
   at System.Web.Configuration.ProvidersHelper.InstantiateProvider(ProviderSettings providerSettings, Type providerType)
   --- End of inner exception stack trace ---
   at System.Web.Configuration.ProvidersHelper.InstantiateProvider(ProviderSettings providerSettings, Type providerType)
   at System.Web.Configuration.ProvidersHelper.InstantiateProviders(ProviderSettingsCollection configProviders, ProviderCollection providers, Type providerType)
   at System.Web.Security.Membership.InitializeSettings(Boolean initializeGeneralSettings, RuntimeConfig appConfig, MembershipSection settings)
   at System.Web.Security.Membership.Initialize()
   at System.Web.Security.Membership.get_Provider()
   at EPiServer.Initialization.MembershipSecurityEntityProviderInitialization.<>c.b__0_1(IServiceLocator s)
   at EPiServer.ServiceLocation.Internal.StructureMapConfiguration.<>c__DisplayClass6_0.b__1(IServiceLocator s)
   at lambda_method(Closure , IBuildSession , IContext )

This is an irritating failure to have, as we have a second AD server that could have been fallen back on. Also, should a role provider become unavailable, I would hope that EPiServer would initialize without it, so our webpages could still be served to the public.

As the initialization process doesn't touch our code anywhere, I can't add code to this effect into the process anywhere:

try{
	InitializeADProviderWithServer(1);
} catch (Exception ex)
{
	try{
		InitializeADProviderWithServer(2);
	} catch (Exception ex)
	{
		log.Error("Failed to connect to either AD server, continuing without AD provider")
	}
}



Is there any means by which I can make this setup resilient so that it falls back to a second server, continues without an AD provider if it can't find one, or preferably, do both?

Web.config extract for Membership Providers:

  
	
	
	
	
	"/>
  
#173710
Edited, Jan 05, 2017 16:43
Vote:
 
#173736
Jan 06, 2017 12:37
Vote:
 

I feel like EPiServer.Initialization.MembershipSecurityEntityProviderInitialization should be capable of catching the ProviderException and handling the error by continuing without that particular provider. Is this configurable or a new feature request?

#173737
Jan 06, 2017 13:34
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.