In SharePoint 2013 when an unauthorized user is logging into the site it gives a message

Sorry, this site is not shared with you

But I am not able to see the User ID of the currently logged in user like we used to see in SP 2010 or SP 2007?

Let me know how to display the logged in User ID on the access denied page.

1 Answer 1


There is no OOTB way for this. However, few customization options are as below:

  1. Create Custom page and run powershell script

    First create three pages and place them in this path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\LAYOUTS\1033\"

    Second Open SharePoint 2013 Management Shell with Farm Administrator User

    Now For Custom access deined page, run the following script:

    $spWebApp.UpdateMappedPage([Microsoft.SharePoint.Administration.SPWebApplication+SPCustomPage]::AccessDenied, "/_layouts/MyPortal/error.aspx");


    Please note that UpdateMappedPage and Set-SPCustomLayoutsPage are not just for access denied. They are used for the following pages:








2.Create an HTTP handler (covered a bit in this forum post) to intercept each request and redirect to your custom page if the server is sending the user to the out of the box accessdenied.aspx page. I don’t like this since it adds overhead to every SharePoint page request.

3.Not a preferable option:

  • Add a delegate control to the error.master like below. (I know, I know. Not ideal)
  • Create a user control to be deployed to _controltemplates
  • Create an elements.xml file which will add the control to the delegatecontrol.
  • On the pageload method of the user control check the request url. If it is for access denied, redirect users to your custom page.

A nice option for those who are ok with modifying out of the box pages.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.