Subscribe:      
 

Creating and Deploying a Custom Login Page for SharePoint 2010 Forms Based Authentication

Written By: MJ Ferdous -- 3/1/2011 -- join -- contribute -- (2923) comments -- printer friendly version

Rating: Rate --

Categories: SharePoint 2010, SharePoint Foundation 2010, System Administration

< Prev - 1 | 2 | 3 | 4 | - Next > | Become a paid author

Step 2:

You have to add a new Application Page with a right-click on the project Solution Explorer -> New item to create Custom Login page

The form will auto-generate some code where you:

  • Need to remove asp:Content ID="Content1" runat="server" from the CustomLogin.aspx
  • Need to remove DynamicMasterPageFile="~masterurl/default.master" from the @Page Register tag
  • Write simple HTML code for the Login Box user interface including username and password textboxes anda  Login Button like below:

Step 3:

  • Add the Microsoft.SharePoint.IdentityModel DLL reference from .\assembly\GAC_MSIL\Microsoft.SharePoint.IdentityModel\14.0.0.0__71e9bce111e9429c \Microsoft.SharePoint.IdentityModel.dll to access SPClaimsUtility
  • Include using Microsoft.SharePoint.IdentityModel; at CustomLogin.aspx.cs
  • Change Inheritance LayoutsPageBase to System.Web.UI.Page
  • Execute the following code inside the Login button click event as below:
    bool status = SPClaimsUtility.AuthenticateFormsUser(
                    Context.Request.UrlReferrer,
                    UserName.Text, 
                    Password.Text);
    if (!status)// if auth failed
    {
        lblError.Text = "Wrong Userid or Password";

    }
    else //if success
    {                
        Response.Redirect("http://fba.contosto.com"); //Use site url
        
    }

Step 4:

Build the solution. Then Deploy the solution package which will create a folder inside .\Microsoft Shared\web server extensions\14\TEMPLATE\LAYOUTS\CustomLoginPageFBA 

< Prev - 1 | 2 | 3 | 4 | - Next >



Learn more about SharePoint



Sponsor Information




Copyright (c) 2010-2017 Edgewood Solutions, LLC All rights reserved
privacy | disclaimer | copyright | advertise | contribute | feedback | about
Some names and products listed are the registered trademarks of their respective owners.


MSSharePointTips.com | MSSQLTips.com