Kicking users from Sitecore

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)

Merry christmas, and happy Sitecore coding.


About briancaos

Developer at Pentia A/S since 2003. Have developed Web Applications using Sitecore Since Sitecore 4.1.
This entry was posted in c#, Sitecore 6 and tagged , , . Bookmark the permalink.

2 Responses to Kicking users from Sitecore

  1. Sasha says:

    And just in case – Sitecore interface (Sitecore 8 specifically):
    [your hostname]/sitecore/client/Applications/LicenseOptions/StartPage


  2. Pingback: Which of my old Sitecore posts are still valid in Sitecore 9? | Brian Pedersen's Sitecore and .NET Blog

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.