If you don’t have sufficient permissions to access a SharePoint resource you are presented with one of three messages. If you have Access requests activated for the site you will see something like this:
From my experience many people tend to think that this is just a plain error message and click it away, followed by an email with the question to please provide the necessary permissions to access the resource. They don’t *really* realize (or know) that they can send a request with a custom message which the admin will read and cause him to react accordingly. That means that the big advantage of sending a request in the context of a resource stays untapped and the email odyssey begins in which you (the admin) try to figure out what the user has just clicked right before this message appeared.
I want to prevent this in the future and I tried to figure out where the message “Let us know why you need access to this site” is stored in order to replace it with a better message that gives some explanation. However, searching with ‘grep’ I couldn’t find the sentence anywhere in the hive. So I decided to hard-code it into the AccessDenied.aspx page.
As I mentioned at the beginning of this post there are two cases:
1: Access requests are not permitted
2: Access requests are permitted
In case 1 there is no text area on the page and thus, it is not possible for the user to send an access request. In that case, the message “Sorry, this site hasn’t been shared with you.” is fine for me and I’ll keep it.
in case 2 I want to replace the text “Let us know why you need access to this site” or “Sorry, you don’t have access to this page” with a much more verbose message:
“You don’t have sufficient permissions to access this site!
If you think that this is a mistake, please write a message in the text box below and click the ‘Send request’ button to send an access request to the administrator of this site.
Thank you!”
Navigate to “c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\LAYOUTS” on your server and make a backup of the file AccessDenied.aspx.
Then open this file and locate the closing tag of:
<asp:Content ContentPlaceHolderId=”PlaceHolderMain” runat=”server”>
Put the following JavaScript snippet directly in front of it:
<script> if(document.getElementById("ms-accessRequestsControl-mainDiv") !== null){ var messageElement = document.getElementById("ms-error-header").children[0] messageElement.style.whiteSpace = 'inherit'; messageElement.style.textAlign = 'justify'; messageElement.style.fontSize = '22px'; messageElement.innerHTML = "<div style='font-size: 26px; font-weight: 400'>" + "You don't have sufficient permissions to access this site!</div><br>" + "If you think that this is a mistake, please write a message in the textbox below and click " + "the 'Send request' button to send an access request to the administrator of this site.<br>" + "<br>Thank you!" } </script>
Chances are that your file will then look like this: (probably less colorful)
Save the file, open your browser and have a look at ‘http://your domain/_layouts/15/AccessDenied.aspx’
And here is what you will get:
I know that this is just a workaround and that it would be better to somehow change the string in a language resource file directly but since I couldn’t find it I chose this way.
If you know a better a way, please let me know in the comments!