Share via


redirect user to custom page instead of access denied page when user has no permission for a list

Question

Wednesday, October 23, 2013 6:56 AM

Hello,

I have this requirement of restricting user to access a list when he doesnot have permissions for that particular list.

Scenario: A page consisting of links to different libraries is created.a user tries to access a document library by clicking on any of the library link. As the user has no permissio to that library, he gets the out of box SharePoint Access Denied page.

My requirement is to instead redirect the user to a custom page that will have a button. When the user clicks on the button, he will be added to the library permission groups and can then access the library.

Problem is this has to be applied to only particular libraries in particular site. We cannot make use of feature(as this should not be applied on all subsites) or SharePoint designer(client doesnot agree).

I tried inserting in AllItems.aspx page a webpart that would check the logged in user on page load of AllItems.aspx of that access library. If logged in user not part of permission group, direct him to any custom page.

But it still gives me the out of box access denied page instead of redirecting to custom page.

I dont want to permanently customise access denied page as this scenario is only for particular libraries.

Can anyone help me out with the solution.

All replies (2)

Thursday, October 24, 2013 9:23 AM ✅Answered

Hi,

According to your post, my understanding is that you wanted to customise access denied page only for particular libraries when user has no permission.

By default, after you customize the site Access Denied, it will be used to all places on the site, to specific to the library, the workaround I can suggest is also from the access denied, we can still considering customize the page. On the custom Access Denied page, check whether the access denied is from the library, this can be checked from the previous page of the Access Denied page, if the previous page url contains the library, then redirect to your custom page specific to the library, otherwise, just redirect to default Access Denied page.

More information:

SharePoint Access Denied Error Page: http://social.technet.microsoft.com/wiki/contents/articles/19687.sharepoint-access-denied-error-page.aspx

Customize the Access Denied Page: http://sharepointdiva.wordpress.com/2012/05/09/customize-the-access-denied-page/

Best Regards,

Linda Li

We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time.
Thanks for helping make community forums a great place.


Thursday, October 24, 2013 9:41 AM ✅Answered

Create a custom page for your error and deploy it on _layout folder or your site also. And change the web.config  file of respective web application and made the customerrormode to on and configure your page.

<configuration>
    <system.web>
        <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
    </system.web>
</configuration>

Regards,

Jayant