I am using Asp.net memebership provider for FBA in sharePoint 2013. Please let me know how to dynamically find membership provider name.
Thanks in advance.
Thanks for the response. My scenario is I am dynamically planning to get membership provider as I have to create token during forms authentication. I found the answer
private static string GetFbaZoneUrl(SPWeb web)
{
string providerAndRole = null;
SPWebApplication webApp = web.Site.WebApplication;
foreach (var zone in webApp.IisSettings.Keys)
{
var settings = webApp.IisSettings[zone];
var fbaProvider = webApp.IisSettings[zone].FormsClaimsAuthenticationProvider;
if (fbaProvider != null)
{
// We found the zone on the web app where FBA is enabled.
// This is the zone whose URL we want.
// SPAlternateUrl fbaUrl = webApp.AlternateUrls.GetResponseUrl(zone, false);
providerAndRole = fbaProvider.MembershipProvider + "," + fbaProvider.RoleProvider;
break;
}
}
return providerAndRole;
}
Hope this code helps someone.
Thanks Rama