SharePoint Online site menu

How to log in to SharePoint as a different user?

SharePoint 2013 and 2016 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!

Solution for logging in as a different user

There’s a URL you can use to automatically log the current user out, and prompt for new credentials. 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. It’s not well known (I guess), 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 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.

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

The following two tabs change content below.

Antti K. Koskela

Solutions Architect / Escalations Engineer at Koskila / Norppandalotti Software / Valo Solutions
Antti Koskela is a proud digital native nomadic millenial full stack developer (is that enough funny buzzwords? That's definitely enough funny buzzwords!), who works as a Solutions Architect for Valo Intranet, the product that will make you fall in love with your intranet. Working with the global partner network, he's responsible for the success of Valo deployments happening all around the world. 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.

Let me know your thoughts!