The following code sample enumerate all Web Application zones. It retrieves the Form Based Authentication zone.Then it retrieves the name of the Membership provider.
Using Microsoft.SharePoint; Using Microsoft.Sharepoint.Administration; . . .
string memberShipProviderName = string.Empty;
SPWeb myWeb = SPContext.Current.Web;
System.Collections.Generic.Dictionary<SPUrlZone, SPIisSettings> myDictionnary = new System.Collections.Generic.Dictionary<SPUrlZone, SPIisSettings>();
myDictionnary = myWeb.Site.WebApplication.IisSettings;
foreach (Microsoft.SharePoint.Administration.SPUrlZone aZone in Enum.GetValues(typeof(Microsoft.SharePoint.Administration.SPUrlZone)))
{
if (myDictionnary.ContainsKey(aZone))
{
if (myDictionnary[aZone].AuthenticationMode == System.Web.Configuration.AuthenticationMode.Forms)
{
memberShipProviderName = myDictionnary[aZone].MembershipProvider.ToString();
}
}
}
1 comment:
Very Useful.
Thanks
Post a Comment