Skip to content

Instantly share code, notes, and snippets.

@pkskelly
Last active January 15, 2019 11:17
Show Gist options
  • Save pkskelly/d894c6588915ddfd7396 to your computer and use it in GitHub Desktop.
Save pkskelly/d894c6588915ddfd7396 to your computer and use it in GitHub Desktop.
Link to log out of Office 365 or SharePoint 2013. Simply copy this file locally, open in a browser and drag the link to the bookmarks bar. Clicking the book mark will force a log out.
<html>
<head>
<title>Logout</title>
</head>
<!-- See http://blog.credera.com/technology-insights/microsoft-solutions/how-to-sign-in-as-a-different-user-in-sharepoint-2013/ for original script-->
<body>
<a href="javascript:
(function()
{
if (typeof SP !== 'undefined')
{
var ctx = new SP.ClientContext.get_current();
var site = ctx.get_site(); ctx.load(site, 'Url');
ctx.executeQueryAsync(Function.createDelegate(this, function (sender, args)
{
var url = site.get_url();
window.location = url + '/_layouts/closeConnection.aspx?loginasanotheruser=true';
}),
Function.createDelegate(this, function (sender, args)
{
alert('Error: ' + args.get_message());
}));
}
else
{
alert('Error: This is not a SharePoint 2010 or 2013 website');
}
})();">O365 Logout</a>
</body>
</html
@kliemohn
Copy link

Excellent find!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment