This is a small xmas special, and a obscure one. Not many people needs to kick users from Sitecore programatically. But if you do you must use the DomainAccessGuard class. The DomainAccessGuard class controls the actual sessions for users that are logged into Sitecore.
This small class allows you to get a list of all current sessions (all users currently logged in), and to kick (log out) any user. I have developed it together with iStern, and you can see iStern’s solution on his blog.
using System.Collections.Generic; using System.Linq; using System.Web; using Sitecore.Web.Authentication; namespace MyNamespace { /// <summary> /// Repository for currently logged in sessions /// </summary> public class SessionsRepository { /// <summary> /// Gets the user sessions sorted with the most active users at the top /// </summary> /// <returns></returns> public IEnumerable<DomainAccessGuard.Session> GetUserSessions() { return DomainAccessGuard.Sessions.OrderByDescending(s => s.LastRequest); } /// <summary> /// Kicks the user session. /// </summary> /// <param name = "sessionID">The session ID.</param> public void KickUserSession(string sessionID) { DomainAccessGuard.Kick(sessionID); } } }
Merry christmas, and happy Sitecore coding.
And just in case – Sitecore interface (Sitecore 8 specifically):
[your hostname]/sitecore/client/Applications/LicenseOptions/StartPage
LikeLike
Pingback: Which of my old Sitecore posts are still valid in Sitecore 9? | Brian Pedersen's Sitecore and .NET Blog