Skip to main content
added 118 characters in body
Source Link
Anders Rask
  • 17.9k
  • 3
  • 39
  • 71

Finally i got it to work :

SPWebApplication app = SPContext.Current.Site.WebApplication;
SPAlternateUrl u = app.AlternateUrls[Request.Url];
SPUrlZone zone = u.UrlZone;
SPIisSettings settings = app.IisSettings[zone];
string components = Request.Url.GetComponents(UriComponents.Query, UriFormat.SafeUnescaped);
string AuthProviderString;
if (flag == 1)
    AuthProviderString = "SAML_STS";
else
    AuthProviderString = "Staging External Users";
foreach (SPAuthenticationProvider provider in settings.ClaimsAuthenticationProviders)
{
    if (string.Compare(provider.DisplayName, AuthProviderString, true, System.Globalization.CultureInfo.CurrentUICulture) == 0
        || string.Compare(provider.ClaimProviderName, AuthProviderString, true, System.Globalization.CultureInfo.CurrentUICulture) == 0)
    {
        string url = provider.AuthenticationRedirectionUrl.ToString();
                       

        SPUtility.Redirect(url, SPRedirectFlags.Default, this.Context, components);
    }
}

http://blog.repsaj.nl/index.php/2010/05/sp2010-creating-a-mixed-mode-login-page-for-claims-based-authentication/

Finally i got it to work :

SPWebApplication app = SPContext.Current.Site.WebApplication;
SPAlternateUrl u = app.AlternateUrls[Request.Url];
SPUrlZone zone = u.UrlZone;
SPIisSettings settings = app.IisSettings[zone];
string components = Request.Url.GetComponents(UriComponents.Query, UriFormat.SafeUnescaped);
string AuthProviderString;
if (flag == 1)
    AuthProviderString = "SAML_STS";
else
    AuthProviderString = "Staging External Users";
foreach (SPAuthenticationProvider provider in settings.ClaimsAuthenticationProviders)
{
    if (string.Compare(provider.DisplayName, AuthProviderString, true, System.Globalization.CultureInfo.CurrentUICulture) == 0
        || string.Compare(provider.ClaimProviderName, AuthProviderString, true, System.Globalization.CultureInfo.CurrentUICulture) == 0)
    {
        string url = provider.AuthenticationRedirectionUrl.ToString();
                       

        SPUtility.Redirect(url, SPRedirectFlags.Default, this.Context, components);
    }
}

Finally i got it to work :

SPWebApplication app = SPContext.Current.Site.WebApplication;
SPAlternateUrl u = app.AlternateUrls[Request.Url];
SPUrlZone zone = u.UrlZone;
SPIisSettings settings = app.IisSettings[zone];
string components = Request.Url.GetComponents(UriComponents.Query, UriFormat.SafeUnescaped);
string AuthProviderString;
if (flag == 1)
    AuthProviderString = "SAML_STS";
else
    AuthProviderString = "Staging External Users";
foreach (SPAuthenticationProvider provider in settings.ClaimsAuthenticationProviders)
{
    if (string.Compare(provider.DisplayName, AuthProviderString, true, System.Globalization.CultureInfo.CurrentUICulture) == 0
        || string.Compare(provider.ClaimProviderName, AuthProviderString, true, System.Globalization.CultureInfo.CurrentUICulture) == 0)
    {
        string url = provider.AuthenticationRedirectionUrl.ToString();
                       

        SPUtility.Redirect(url, SPRedirectFlags.Default, this.Context, components);
    }
}

http://blog.repsaj.nl/index.php/2010/05/sp2010-creating-a-mixed-mode-login-page-for-claims-based-authentication/

Finally i got it to work : SPWebApplication app = SPContext.Current.Site.WebApplication; SPAlternateUrl u = app.AlternateUrls[Request.Url]; SPUrlZone zone = u.UrlZone; SPIisSettings settings = app.IisSettings[zone]; string components = Request.Url.GetComponents(UriComponents.Query, UriFormat.SafeUnescaped); string AuthProviderString; if (flag == 1) AuthProviderString = "SAML_STS"; else AuthProviderString = "Staging External Users";

  SPWebApplication app = SPContext.Current.Site.WebApplication;
SPAlternateUrl u = app.AlternateUrls[Request.Url];
SPUrlZone zone = u.UrlZone;
SPIisSettings settings = app.IisSettings[zone];
string components foreach= Request.Url.GetComponents(SPAuthenticationProvider provider inUriComponents.Query, settingsUriFormat.ClaimsAuthenticationProvidersSafeUnescaped);
               string {AuthProviderString;
                if (flag == 1)
                  AuthProviderString = "SAML_STS";
    else
    AuthProviderString = "Staging External Users";
foreach (SPAuthenticationProvider provider in settings.ClaimsAuthenticationProviders)
{
    if (string.Compare(provider.DisplayName, AuthProviderString, true, System.Globalization.CultureInfo.CurrentUICulture) == 0
                        || string.Compare(provider.ClaimProviderName, AuthProviderString, true, System.Globalization.CultureInfo.CurrentUICulture) == 0)
                    {
                        string url = provider.AuthenticationRedirectionUrl.ToString();
                       

                        SPUtility.Redirect(url, SPRedirectFlags.Default, this.Context, components);
                    }
                }

Finally i got it to work : SPWebApplication app = SPContext.Current.Site.WebApplication; SPAlternateUrl u = app.AlternateUrls[Request.Url]; SPUrlZone zone = u.UrlZone; SPIisSettings settings = app.IisSettings[zone]; string components = Request.Url.GetComponents(UriComponents.Query, UriFormat.SafeUnescaped); string AuthProviderString; if (flag == 1) AuthProviderString = "SAML_STS"; else AuthProviderString = "Staging External Users";

                foreach (SPAuthenticationProvider provider in settings.ClaimsAuthenticationProviders)
                {
                   
                    
                    if (string.Compare(provider.DisplayName, AuthProviderString, true, System.Globalization.CultureInfo.CurrentUICulture) == 0
                        || string.Compare(provider.ClaimProviderName, AuthProviderString, true, System.Globalization.CultureInfo.CurrentUICulture) == 0)
                    {
                        string url = provider.AuthenticationRedirectionUrl.ToString();
                       

                        SPUtility.Redirect(url, SPRedirectFlags.Default, this.Context, components);
                    }
                }

Finally i got it to work :

SPWebApplication app = SPContext.Current.Site.WebApplication;
SPAlternateUrl u = app.AlternateUrls[Request.Url];
SPUrlZone zone = u.UrlZone;
SPIisSettings settings = app.IisSettings[zone];
string components = Request.Url.GetComponents(UriComponents.Query, UriFormat.SafeUnescaped);
string AuthProviderString;
if (flag == 1)
    AuthProviderString = "SAML_STS";
else
    AuthProviderString = "Staging External Users";
foreach (SPAuthenticationProvider provider in settings.ClaimsAuthenticationProviders)
{
    if (string.Compare(provider.DisplayName, AuthProviderString, true, System.Globalization.CultureInfo.CurrentUICulture) == 0
        || string.Compare(provider.ClaimProviderName, AuthProviderString, true, System.Globalization.CultureInfo.CurrentUICulture) == 0)
    {
        string url = provider.AuthenticationRedirectionUrl.ToString();
                       

        SPUtility.Redirect(url, SPRedirectFlags.Default, this.Context, components);
    }
}
Source Link
Nikhil J
  • 4.9k
  • 10
  • 47
  • 91

Finally i got it to work : SPWebApplication app = SPContext.Current.Site.WebApplication; SPAlternateUrl u = app.AlternateUrls[Request.Url]; SPUrlZone zone = u.UrlZone; SPIisSettings settings = app.IisSettings[zone]; string components = Request.Url.GetComponents(UriComponents.Query, UriFormat.SafeUnescaped); string AuthProviderString; if (flag == 1) AuthProviderString = "SAML_STS"; else AuthProviderString = "Staging External Users";

                foreach (SPAuthenticationProvider provider in settings.ClaimsAuthenticationProviders)
                {
                   
                    
                    if (string.Compare(provider.DisplayName, AuthProviderString, true, System.Globalization.CultureInfo.CurrentUICulture) == 0
                        || string.Compare(provider.ClaimProviderName, AuthProviderString, true, System.Globalization.CultureInfo.CurrentUICulture) == 0)
                    {
                        string url = provider.AuthenticationRedirectionUrl.ToString();
                       

                        SPUtility.Redirect(url, SPRedirectFlags.Default, this.Context, components);
                    }
                }