SharePoint developers and IT pros are familiar with the “sign in as different user” menu option in SharePoint 2010. However, in Microsoft SharePoint Server 2013, you will notice that this menu option is missing.
Within the SharePoint community, a number of reasons have been suggested as to why Microsoft decided to remove this menu option.
Some of the reasons are:
- “Sign in as different user” does not clear cookies and session variables.
- Since external applications generally run under the currently logged in Windows user account and not the account logged in to SharePoint, documents opened in these applications often end up being saved with an unexpected user account.
- Cache conflicts occur often. Since the cache for one user wouldn’t (and shouldn’t) match that for another user, pages may display data and content specific to a previously logged in user.
For those unfamiliar with this menu option, here’s how it looks in SharePoint 2010:
In this article, I have logged all the solutions and workarounds to this problem that I have found so far. Feel free to add your solution in the comments section.
Access the SharePoint site by using the the URL as http://siteurl/_layouts/closeConnection.aspx?loginasanotheruser=true
This option uses an unsupported browser feature which is unreliable and causes other issues.
Currently this option does not work in IE 10 and Safari.
Reference: Microsoft KB article.
Start Internet Explorer by using the Run as different user option, and then go to the SharePoint site.
The Run as different user option is visible if you hold the Shift key when you right-click a program icon.
This is similar to Solution #2 but saves you a few clicks by using a desktop shortcut.
- Create a shortcut to your favorite browser. In Windows and for Internet Explorer, do this by navigating to C:\Program Files (x86)\Internet Explorer and dragging iexplore.exe to the desktop (by default this creates a shortcut). For non 64 bit Windows, go to C:\Program Files\Internet Explorer instead.
- Right click your new shortcut and select “Properties”.
- Modify the shortcut target by adding runas and the desired user account to the beginning of the path. Change the target to (replace user@domain with your test acct):
%systemroot%\System32\runas.exe /user:user@domain “%ProgramFiles(x86)%\Internet Explorer\iexplore.exe” or for non 64 bit Windows: %systemroot%\System32\runas.exe /user:user@domain “%ProgramFiles%\Internet Explorer\iexplore.exe”
- Click OK to save changes.
Double-click your new shortcut and you’ll get a prompt to enter a password. You won’t see anything on the screen as you type, so just go on faith. Type your password and hit enter.
To install this fix simply drag the link below to your favorites bar to create a bookmarklet that will work on any SharePoint 2013 site. You could also just right-click on the link in Internet Explorer and press Add to favorites.
Whenever you want to log in as another user simply click your bookmark and you’ll be redirected to this Windows Authentication dialog so that you may log in as you would expect.
Here’s The Link: Sign In As Different User
Note: It only works from within a SharePoint site.
This solution adds a custom action to the SharePoint standard menu. This is done in Visual Studio and entirely in the Elements.xml file and deployed as a compiled .WSP file.
If you are unfamiliar with manipulating custom actions, or if you want to add triggers etc, or if you want to do this from C# code within the feature activated event, please have a look at my previous articles about custom actions: This one is about adding a custom action to the Edit Control Block and this one is about adding a custom action to the SharePoint Ribbon. With guidance from those links, you can easily convert this xml code to “debuggable” C# code.
Here’s the Elements.xml code:
<?xml version="1.0" encoding="utf-8"?> <Elements xmlns="http://schemas.microsoft.com/sharepoint/"> <CustomAction Id="MyLoginDifferentUser" GroupId="PersonalActions" Location="Microsoft.SharePoint.StandardMenu" Sequence="1000" Title="Sign in as Different User"> <UrlAction Url="/_layouts/closeConnection.aspx?loginasanotheruser=true"/> </CustomAction> </Elements>
NOTE: This solution involves modifying files in the hive and is not generally good practice. Not recommended by Microsoft either. I only recommend something like this if you’re playing on your DEV machine. It is presented here as a quick (and dirty!) solution.
Read on all the same… You might find the knowledge quite useful.
Locate and open the following file in a text editor:
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\CONTROLTEMPLATES\Welcome.ascx (create a backup first).
Add the following element before the existing “ID_RequestAccess” element:
<SharePoint:MenuItemTemplate runat="server" ID="ID_LoginAsDifferentUser" Text="<%$Resources:wss,personalactions_loginasdifferentuser%>" Description="<%$Resources:wss,personalactions_loginasdifferentuserdescription%>" MenuGroupId="100" Sequence="100" UseShortId="true" />
Save the file. Done. Now, the “Sign in as different user” menu option will be displayed.
Final Note: The sign in as different user functionality is not meant to be used as a security feature. This feature allows users which have more than one AD account to quickly login with a different account to SharePoint – but it does not guarantee that no artifacts from the previous user remain. If you have to guarantee that one user cannot see data from a different user you have to logoff/logon in Windows. Don’t use the Sign in as a different user.