SharePoint offers an out-of-box authentication flow that applies for most real-world scenarios. But unfortunatelly, one situation is not well designed (IMHO…) and demands a small customization. Let’s say you stumble on an Access Denied page you won’t have an easy option to sign out and try with another user. There’s no shortcut to Sign in as different user on Access Denied page.
The option to quickly sign out and sign in with another user account is great when you are testing permissions for multiple users. Also, your test context situation gets worse if you are using Integrated Authentication and your Windows user account is the same as your SharePoint user, you won’t be able to type any credentials at all because it will keep you getting authenticated everytime you open the SharePoint site.
You will keep seeing the message below:
Adding the Sign in as different user link
We could talk about the Access Requests feature that improves the user experience and let them be more proactive, requesting access to the Site Admins. But if you just want to sign in as a different user in the computer of your colleague, what if you could just hit a “Sign out button” and type the credentials as you want?
In the code snippet ahead I’ve just duplicated the out-of-box Access Denied page and added a Sign out link. This link redirects the user to the Close Connection page, while passing a QueryString that asks SharePoint to let the user enter the credentials again:
Replacing the Access Denied page
The page above will be placed in all our Web Front End servers inside the LAYOUTS folder. It won’t be replaced by any SharePoint upgrade and we will be safe to run the powershell as follows:
This powershell will make SharePoint redirect you to our custom Signout Page without any overhead or development involved. Finally the users will now be able to sign out and try other credentials if they want.
Hope this post can help you on improving your testing experience when you need to Sign in as different user on access denied page. Furthermore, you can check other posts about SharePoint customizations here too.
References:
Docs Microsoft
Very good, this post saved my life.
Thanks!!!