69 lines
2.0 KiB
C#
69 lines
2.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Web.Configuration;
|
|
using System.Web.Script.Serialization;
|
|
using System.Web.Security;
|
|
using Microsoft.SharePoint;
|
|
using Microsoft.SharePoint.Administration;
|
|
|
|
namespace Taloyhtio.CustomFBADataSource.CodeFiles
|
|
{
|
|
// Contains copy/pasted methods from CKS.FormsBasedAuthentication
|
|
public class Utils
|
|
{
|
|
public static bool IsProviderConfigured()
|
|
{
|
|
// attempt to get current users details
|
|
try
|
|
{
|
|
Membership.GetUser();
|
|
}
|
|
catch
|
|
{
|
|
// if fails membership provider is not configured correctly
|
|
return false;
|
|
}
|
|
|
|
// if no error provider is ok
|
|
return true;
|
|
}
|
|
|
|
public static SPIisSettings GetFBAIisSettings(SPSite site)
|
|
{
|
|
SPIisSettings settings = null;
|
|
|
|
// try and get FBA IIS settings from current site zone
|
|
try
|
|
{
|
|
settings = site.WebApplication.IisSettings[site.Zone];
|
|
if (settings.UseFormsClaimsAuthenticationProvider)
|
|
return settings;
|
|
}
|
|
catch
|
|
{
|
|
// expecting errors here so do nothing
|
|
}
|
|
|
|
// check each zone type for an FBA enabled IIS site
|
|
foreach (SPUrlZone zone in Enum.GetValues(typeof(SPUrlZone)))
|
|
{
|
|
try
|
|
{
|
|
settings = site.WebApplication.IisSettings[(SPUrlZone)zone];
|
|
if (settings.UseFormsClaimsAuthenticationProvider)
|
|
return settings;
|
|
}
|
|
catch
|
|
{
|
|
// expecting errors here so do nothing
|
|
}
|
|
}
|
|
|
|
// return null if FBA not enabled
|
|
return null;
|
|
}
|
|
}
|
|
}
|