Thursday 10 April 2014

How to apply custom login page for sharepoint webapplication


In order to accomplish this we need to follow the below steps:

Steps 

  • Create a new Application page and deploy the page in a different location in "_layouts" folder. for ex: "_layouts/login"

  • We need to execute few powershell commands to replace the outofbox login page to the new page that we created. For easy use I have written a powershell script to execute set of commands at once.

  • Create a powershell script and add the below code

1:  Add-PsSnapin Microsoft.SharePoint.PowerShell  
2:  $WebAppURL= read-host "Enter the web application URL to which wish to set the Custom Login Page"  
3:  Set-SPCustomLayoutsPage -Identity "Login" -RelativePath "/_layouts/Login/Default.aspx" -WebApplication $WebAppURL  
4:  Remove-PsSnapin Microsoft.SharePoint.PowerShell  
  • The above script will prompt for application url for which you want to set the custom login page.

  • we need to make the below change in Web.config along with the above script execution

   <authentication mode="Forms">
      <forms loginUrl="/_layouts/login/default.aspx" />
    </authentication>

Note: we need to follow the same process above in order to apply custom Access denied page. 

1:  Set-SPCustomLayoutsPage -Identity "AccessDenied" -RelativePath "/_layouts/Login/AccessDenied.aspx" -WebApplication $WebAppURL   


 

No comments:

Post a Comment