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=%2F. This 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.
Good mentioning on required ReturnUrl query string value and SPAuthenticationProvider.AuthenticationRedirectionUrl.
Thanks.
I cretes a user control in sp project and trying to get users windows login id.
how can i get user’d login id ?
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.
Pingback: SharePoint Anonymous access page auto login javascript | SharePoint Q&A