This post was most recently updated on December 16th, 2018.
SharePoint Server versions 2013, 2016 and 2019 don’t have that old and familiar “sign in as a different user” -option in the site menu, and for the time being, nor does SharePoint Online. However, sometimes it’s very useful functionality to have, so it’s a bit weird Microsoft chose to get rid of the option.
This post outlines a method that I’ve found to work quite well for making SharePoint ask for credentials, so that you can use another account to then log in! Really nice feature (or shortcut) to have, when trying to administer, debug or demonstrate something on the site!
Solution for logging in as a different user
There’s an URL you can use to automatically log the current user out, and prompt for new credentials. That powered the out-of-the-box functionality of SharePoint 2010, too. While the shortcut (menu option) has been removed, the URL still works! See below for different options!
When you aim to log out of your current SharePoint session, SharePoint redirects you to an url like this to sign you out:https://[site or web address]/_layouts/closeConnection.aspx
Okay – so that page can sign you out. Very useful!
It’s apparently not that well known, but it can actually also make you log in again (as another, or if you want to, the same user). It can even redirect you somewhere else after logging in, if you so desire!
So, how to achieve this?
Quite easy. The page supports a number of url parameters, such as loginasanotheruser and source.
To log in again after logging out, this modification to the url should do the trick:https://[site or web address]/_layouts/closeConnection.aspx?loginasanotheruser=true
It effectively ends the session and asks for new username and password with the basic authentication pop-up.
And if you need a redirection for a case such as one, where a user is required to use other credentials when entering a site through a link, one can use a link like this:https://[site or web address]/_layouts/closeConnection.aspx?loginasanotheruser=true&Source=[newsite]
And here you go! You should be able to sign in as a different user now, and redirect the user to any page afterwards.
Resources or credits
More or less inspired by this, unanswered Stack Exchange post: http://sharepoint.stackexchange.com/questions/135517/sharepoint-2013-implement-simple-logout-button-which-do-not-redirect-to-default
He's been a developer from 2004 (starting with PHP and Java), and he's been bending and twisting SharePoint into different shapes since MOSS. Nowadays he's not only working on SharePoint, but also on .NET projects, Azure, Office 365 and a lot of other stuff.
This is his personal professional (e.g. professional, but definitely personal) blog.
Latest posts by Antti K. Koskela (see all)
- SharePoint linguistic search features - March 20, 2019
- How to remove Azure Functions without deleting the Functions App? - March 20, 2019
- EntityFramework Core 2.1 – Update-Database error “The EntityFramework package is not installed” - March 19, 2019