URL for Windows Authentication in SharePoint 2010

When using Claims Authentication in SharePoint 2010 you can configure multiple authentication providers for your site. Specifically, you can use both Windows Authentication and Form Based Authentication – and your site users can choose which method to use to authenticate to your site. This is also referred to as Mixed Mode Authentication.

When Mixed Mode Authentication is enabled, the URL that would perform the Windows Authentication is /_windows/default.aspx. This means navigating to http://server/siteCollection/_windows/default.aspx will automatically log you in to that site collection using Windows Authentication (even when Mixed Mode Authentication is enabled).

The URL above requires a returning URL to be passed in as part of the query string. The full URL you should use is http://server/siteCollection/_windows/default.aspx?ReturnUrl=%2f_layouts%2fAuthenticate.aspx%3fSource%3d%252F&Source=%2FThis URL will authenticate the user using Windows Authentication and takes the user to the landing page of the site.

This is useful, for example, when you customise the login page. Your page could have the standard Username/password textboxes (as most of your users are external users that would rely on Form Based Authentication). You could then add a link to the above URL for the few internal users (who would be using Windows Authentication).

As a side note, you could use the code below to query the SharePoint object model to identify the URL used by the 2 authentication providers:

using (var site = new SPSite("http://yourServer"))
			{
				SPWebApplication webApplication = site.WebApplication;
				SPUrlZone urlZone = webApplication.AlternateUrls[site.Url].UrlZone;
				SPIisSettings settings = webApplication.IisSettings[urlZone];

				foreach (SPAuthenticationProvider provider in settings.ClaimsAuthenticationProviders)
				{
					Console.WriteLine(provider.DisplayName + ": " + provider.AuthenticationRedirectionUrl);
				}
			}

Another side note, the URL to sign-out is http://server/siteCollection/_layouts/signout.aspx.

Advertisements

About Bernado

Based in Australia, I am a freelance SharePoint and Dynamics CRM developer. I love developing innovative solutions that address business and everyday problems. Feel free to contact me if you think I can help you with your SharePoint or CRM implementation.
This entry was posted in Claim Authentication, SharePoint 2010. Bookmark the permalink.

4 Responses to URL for Windows Authentication in SharePoint 2010

  1. Tinminator says:

    Good mentioning on required ReturnUrl query string value and SPAuthenticationProvider.AuthenticationRedirectionUrl.
    Thanks.

  2. Kevin says:

    I cretes a user control in sp project and trying to get users windows login id.
    how can i get user’d login id ?

    • Bernado says:

      If the user control is being used in SharePoint, and your site is using Windows Authentication, and the user has already logged in, you can get the user’s login ID using SPContext.Current.Web.CurrentUser.LoginName.

  3. Pingback: SharePoint Anonymous access page auto login javascript | SharePoint Q&A

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s