The code behind of the login page the mappings are retrieved, the IP address of the request is checked against the mappings, and if an authentication provider is found the user is redirected to the provider’s sign-in page.
protected override void OnLoad(EventArgs e)
{
if (SPContext.Current == null) return;
if (SPContext.Current.Site == null) return;
if (SPContext.Current.Site.WebApplication == null) return;
SPWebApplication app = SPContext.Current.Site.WebApplication;
SignInConfiguration config = app.GetChild<SignInConfiguration>("SignInConfig");
SPAlternateUrl u = app.AlternateUrls[Request.Url];
SPUrlZone zone = u.UrlZone;
string components = Request.Url.GetComponents(UriComponents.Query, UriFormat.SafeUnescaped);
SPIisSettings settings = app.IisSettings[zone];
string ip = IpNetworking.GetIP4Address();
ip = Regex.Replace(ip, @"^(?<Prefix>(\d{1,3}\.){3})\d{1,3}$", "${Prefix}*");
if (config != null && config.ProviderMappings.ContainsKey(ip))
{
string targetProvider = config.ProviderMappings[ip];
foreach (SPAuthenticationProvider provider in settings.ClaimsAuthenticationProviders)
{
if (string.Compare(provider.DisplayName, targetProvider, true, System.Globalization.CultureInfo.CurrentUICulture) == 0
|| string.Compare(provider.ClaimProviderName, targetProvider, true, System.Globalization.CultureInfo.CurrentUICulture) == 0)
{
string url = provider.AuthenticationRedirectionUrl.ToString();
if (provider is SPWindowsAuthenticationProvider)
{
components = EnsureReturnUrl(components);
}
SPUtility.Redirect(url, SPRedirectFlags.Default, this.Context, components);
}
}
}
else
{
SPUtility.Redirect("/_forms/default.aspx", SPRedirectFlags.Default, this.Context, components);
}
base.OnLoad(e);