I am creating a Claims based authentication using PowerShell. I am enabling both Windows authentication and FBA. My code will look as follows:

    $authMethod = "NTLM"
Write-Output "Creating $title web application on port $port..." 
$waexe = "New-SPWebApplication -Name $title -ApplicationPool $title -ApplicationPoolAccount(Get-SPManagedAccount `$managedAccount)"
$waexe += " -Url $waurl -Port $port"
$waexe += " -DatabaseName $databaseName"
$waexe += " -AuthenticationMethod $authMethod"
$winap = New-SPAuthenticationProvider -UseWindowsIntegratedAuthentication -DisableKerberos 
$fbap = New-SPAuthenticationProvider -ASPNETMembershipProvider $membership -ASPNETRoleProviderName $rolemanager             
$waexe += " -AuthenticationProvider (`$winap,`$fbap)"
if($signInRedirectUrl -ne $null)
    $waexe += " -SignInRedirectURL $signInRedirectUrl"
$prxyGroup = Get-SearchProxyGroup
if($prxyGroup -ne $null)
    $waexe += " -ServiceApplicationProxyGroup `$prxyGroup"
$waexe += " -ErrorVariable err -ErrorAction SilentlyContinue"   
$waexe += " | Out-Null"     

Write-Output $waexe

Invoke-Expression $waexe

The application gets created fine. When i try to browse the site, it redirect to custom sign-on page.

But if something WRT to FBA has failed, it wouldn't allow me to login using Windows authentication. When i try to access default login page "_login/default.aspx", it still redirects to custom sign-in page.

How can i login using windows authentication. My crawl component can successfuly crawl the site using Windows authentication.

2 Answers 2


As I noted in my comment above, I think navigating to "_windows/default.aspx" will redirect you to the custom login page.

I think the best approach would be to add an option to your custom login page to login using Windows Authentication. You can present the user with the username/password as being the default method for login, but have a link or button somewhere on the page where they can login using Windows Authentication...maybe call it Admin Login. You could have the link or button call the following code to redirect to the page associated with logging in via Windows Authentication.

    private void GetWindowsAuthenticationProvider()
        Microsoft.SharePoint.Administration.SPIisSettings settings = Microsoft.SharePoint.SPContext.Current.Site.WebApplication.GetIisSettingsWithFallback(Microsoft.SharePoint.SPContext.Current.Site.Zone);
        foreach (Microsoft.SharePoint.Administration.SPAuthenticationProvider provider in settings.ClaimsAuthenticationProviders)
            if (provider is Microsoft.SharePoint.Administration.SPWindowsAuthenticationProvider)
                string components = System.Web.HttpContext.Current.Request.Url.GetComponents(UriComponents.Query, UriFormat.SafeUnescaped);
                string url = provider.AuthenticationRedirectionUrl.ToString();
                Microsoft.SharePoint.Utilities.SPUtility.Redirect(url, Microsoft.SharePoint.Utilities.SPRedirectFlags.Default, this.Context, components);
  • Much better answer then mine (+1). In recent project I had some problems implementing similar code. Users were never asked for windows credentials so I ended with redirecting them to _windows/default.aspx (look at my edited answer). After that everything start to work as expected. Any idea why? (if you debug your code you will notice that url = '_windows/default.aspx') Jul 23, 2011 at 20:45
  • Right...the page it redirects to is "_windows/default.aspx", but when you type an address into the address bar of a web browser it's not performing a redirect operation. Given that, I'm going to assume that the code-behind for the windows auth page is looking for a redirect.
    – Rob D'Oria
    Jul 23, 2011 at 21:28

You can log using windows authentication by accessing '_windows/default.aspx'


After reading Robs comment I did some double checking. By simply entering '_windows/default.aspx' in your browser you will be redirected to default (or custom) login page. But if you are using this block of code in your custom login page you will be asked for windows credendials:

protected void Page_Load(object sender, EventArgs e)
    var components = Request.Url.GetComponents(UriComponents.Query, UriFormat.SafeUnescaped);
    SPUtility.Redirect("/_windows/default.aspx", SPRedirectFlags.Default, Context, components);

This piece of code was source for my answer. My mistake was that it was not included in original answer.

  • I think navigating to "_windows/default.aspx" will redirect you to the custom login page as well.
    – Rob D'Oria
    Jul 23, 2011 at 13:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.