SharePoint Online site menu

How to log in to SharePoint as a different user?

This post was most recently updated on August 29th, 2020.

Reading Time: 3 minutes.

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. If you want to redirect the user to a new site after they’ve logged in as a new user, you’ll need these both. The simple steps below should outline how you can craft the url for this use case:

Time needed: 5 minutes.

How to use “_layouts/closeconnection.aspx?loginasanotheruser=true” to redirect users to a new address after logging in?

  1. Figure out the address of your site

    Any SharePoint Site (or “Site Collection”, as they used to be called) has closeConnection.aspx deployed to it, so just grab the address. An example would be as follows:

    https://contoso.sharepoint.com/sites/home

    Hence, the address to log users out and sign them in as another one would be as follows:

    https://[site or web address]/_layouts/closeConnection.aspx?loginasanotheruser=true

    It effectively ends the session and asks for new username and password with the authentication pop-up.

  2. Define the address you want to direct the users to

    This one is up to you obviously. It can be an URL in SharePoint, or pretty much anything else that’s covered by the same single-sign-on (SSO).

    For our example here, let’s use another SharePoint site, https://contoso.sharepoint.com/sites/teamsite

  3. Combine the redirect url with the closeConnection.aspx page using “Source” parameter

    The link will be something like this.

    https://contoso.sharepoint.com/sites/home/_layouts/closeConnection.aspx?loginasanotheruser=true&Source=https://contoso.sharepoint.com/sites/teamsite

    And you should be good!

And here you go! You should be able to sign in as a different user now, and redirect the user to any page afterwards.

References

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

mm
0 0 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments