SharePoint 2010 Customizing the Sign-in page for SQL forms-based authentication

Source: Internet
Author: User

When you configure SharePoint WebApplication to login in mixed mode (FBA authentication and Windows authentication), we can of course customize the landing page (sign in page).

Once you have logged in to SharePoint Central Administratio, locate the corresponding WebApplication and specify its sign in Page URL, as shown below:

Ii. Creating a custom login project

    • First, in order to create a custom landing page, I selected the Application page, which will be deployed by default in layouts and the same folder as the project name (C:\Program files\common Files\Microsoft Shared\Web Server extensions\14\template\layouts).
    • Next, to prevent the master page from affecting the application page, you must remove the reference to the master page, which is DynamicMasterPageFile = "~masterurl/default.master"
    • Login control based on form validation (FBA) has selected the ASP. Set its related properties. Take the common attributes as an example:
  • FailureText: Message to prompt when login fails
  • MembershipProvider: Custom Membership Provider, you need to inherit MembershipProvider, see the SharePoint 2013 customizing providers application in forms-based authentication (forms-based-authentication)
  • Displayrememberme:bool type that indicates whether to show remember me
  • Remembermeset: Indicates whether persistent authenticated cookies are sent to the user's browser, false by default
  • TextLayout: There are 2 options, textonleft (label in TextBox left), Textontop (label on textbox)
  • Usernamelabeltext: User name label display text
  • Passwordlabeltext: Password Label display text
  • Loginbuttontype: There are 3 kinds of options, Image, Button,image
  • Loginbuttonimageurl: If Loginbuttontype selects an image, this property represents the image address
    • The complete Login control code is as follows:
<Asp:loginId= "Signincontrol"Style= "width:250px"FailureText= "User name or password error"MembershipProvider= "Customfba_membership"Runat= "Server"Displayrememberme= "true"Textboxstyle-width= "250px"Remembermeset= "true"Usernamelabeltext= "User Name"TextLayout= "Textonleft"Passwordlabeltext= "Password"Labelstyle-font-bold= "false"Labelstyle-font-size= "Large"Labelstyle-forecolor= "Red"Labelstyle-font-names= "Song Body"Checkboxstyle-font-bold= "false"Checkboxstyle-font-names= "Song Body"Checkboxstyle-forecolor= "White"Checkboxstyle-font-size= "Large"Failuretextstyle-wrap= "true"Failuretextstyle-font-names= "Song Body"Failuretextstyle-font-size= "Small"Loginbuttonstyle-font-names= "Song Body" Loginbuttonstyle-font-size=" Large " Loginbuttonimageurl= "/_layouts/images/loginbtn.png"  Loginbuttontype=" Image "  Titletext= "Landed"  Titletextstyle-forecolor= "green" = "true"  Titletextstyle-wrap = "true"  Titletextstyle-font-names= " Titletextstyle-font-size=" Larger "/>                

The forms-based authentication login has been designed so far, but let's not forget that I also need the login implementation of Windows authentication (that is, acrive Directory login).

    • Add a hyperlink To enable Windows Authentication login
<asp:linkbutton id= " Lbinternalusers " Text=" Active Directory Login " Runat= "Server"  font-names = "Arial"  Font-size= " Small " Cssclass=" Ms-standardheader Ms-inputformheader " Font-bold=" true " Forecolor= "Wheat"  OnClick = "Lbinternalusers_onclick" />     
    • Implementing a domain account login in its Click event
Protectedvoid Lbinternalusers_onclick (Objectsender, EventArgs e) {Try{if (Null! = Spcontext.current &&Null! =SPContext.Current.Site) {Spiissettings iissettings =Spcontext.current.site.webapplication.iissettings[spurlzone.default];if (Null! = Iissettings &&Iissettings.usewindowsclaimsauthenticationprovider) {Spauthenticationprovider Provider =Iissettings.windowsclaimsauthenticationprovider; Redirect (provider); } } }Catch(Exception ex) { } }PrivatevoidRedirect (Spauthenticationprovider provider) {String comp =HttpContext.Current.Request.Url.GetComponents (Uricomponents.query, uriformat.safeunescaped);String url =Provider. Authenticationredirectionurl.tostring ();if (providerIsSpwindowsauthenticationprovider) {comp = Ensureurl (comp,True); } sputility.redirect (URL, Spredirectflags.default,This. Context, comp); }//Http://skyrim: 6050/_windows/default.aspx? Returnurl=PrivateString Ensureurl (String URL,boolUrlisquerystringonly) {if (!url. Contains ("Returnurl=")) {If(urlisquerystringonly) {url = url + (String. IsNullOrEmpty (URL)?"" : "&" ); } else ? ") = =-1)?  "?":  "&" ); url = url +  "returnurl=" return URL;        
Modify the default sign in Page
    • When the custom sign in page finishes, assign the URL to Webapplicatio as follows:

    • Test the form-based authentication login to verify that it is working properly and send a cookie named Fedauth to the client after successful login

    • Test Windows-based authentication login to verify that it is working correctly

Summarize

For the name of the custom ASP. NET login control, note that the name must be:Signincontrol, I have been tangled for a long time (exception information, after successful login still shows invalid authentication, redirect to:/ Authenticate.aspx? SOURCE=%2F, and sends a cookie named Aspxauth to the client, and when the client browser remembers the wrong Aspxauth cookie, the next visit returns an internal error of 500. After clearing this cookie, it returns to normal). There is no time to reflect the SharePoint original login control, and I estimate that the name of the default login control is also:Signincontrol. There are some points of attention, but also tangled up with me for a long time, see my attachment. Click to download

Transferred from: http://www.cnblogs.com/OceanEyes/p/how-to-create-custom-sign-in-page.html

SharePoint 2010 Customizing the Sign-in page for SQL forms-based authentication

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.