Fix for Security and Indexing Events – Sitecore 8.1

Recently I played around with Security and Indexing events but was not able to get them to work on the latest Sitecore 8.1 rev. 151207 (Update-1) version. However, I was unable to trigger any events.

This issue involves two event groups:
security:loggedIn
security:loggedOut

index:start:rebuild
index:end:rebuild

It turns out that these events don’t work properly in Sitecore 8.1 rev. 151207.

Sitecore Support has provided workarounds for these two cases, which I will describe below.
Hopefully, this will save you some time as you work with these events in the current version of Sitecore.

To track the future status, Sitecore has provided the following reference numbers:
‘Security’ bug report reference number: 90553
‘Indexing’ bug report: 422607

1. Security Events.

security:loggedIn and security:loggedOut events aren’t triggered at all.

As a workaround, Sitecore recommends using processors instead.

For a helpful illustration of how to configure Security events, take a look at this article.
From the article, you will end up configuring events like the example shown below:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <events>
      <event name="security:loggedIn">
        <handler type="Events.Events, Events" method="OnLoggedIn"/>
      </event>
      <event name="security:loggedOut">
        <handler type="Events.Events, Events" method="OnLoggedOut" />
      </event>
    </events>
  </sitecore>
</configuration>

However, you should change this config and use processors instead:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <processors>
      <loggedin>
        <processor mode="on" type="Events.LoggedIn, Events"/>
      </loggedin>
      <logout>
        <processor mode="on" type="Events.LogOut, Events"/>
      </logout>
    </processors>
  </sitecore>
</configuration>

Event handler code:

namespace Events
{
    public class LoggedIn
    {
        public void Process(LoggedInArgs args)
        {

        }
    }
}

2. Index Events.

index:start:rebuild and index:end:rebuild events are mentioned in sources like this

However, these events are deprecated. Starting from Sitecore 7, you should use ‘indexing:start/indexing:end’ instead.

So your config should look like this:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <events>
      <event name="indexing:start">
        <handler type="Events.Events, Events" method="OnIndexingStart" />
      </event>
      <event name="indexing:end">
        <handler type="Events.Events, Events" method="OnIndexingEnd" />
      </event>
    </events>
  </sitecore>
</configuration>

And code:

namespace Events
{
    public class Events
    {
        public void OnIndexingStart(object sender, EventArgs args)
        {
            
        }
        public void OnIndexingEnd(object sender, EventArgs args)
        {
            
        }
    }
}

Unfortunately, even after this change, ‘Indexing’ events will not be raised if you start an index rebuild from
Control panel -> Indexing -> Index Manager.

But if you start the reindex process from ‘Rebuild All at Developer tab -> Indexing tools chunk’, Index events will work as expected.

Sitecore Support has provided a patch to fix the indexing issue from the “Control panel ->Indexing -> Index Manager” location.

You can find patches here.

To enable patches:
1. Place the Sitecore.Support.406929.dll assembly into the Bin folder;
2. Place the IndexingManager.xml file into the Website\sitecore\shell\Override folder;

Thanks to Sitecore support for providing this info!

This entry was posted in C#, Sitecore and tagged , . Bookmark the permalink.

Leave a Reply

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

WordPress.com Logo

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

Google+ photo

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

Twitter picture

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

Facebook photo

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

Connecting to %s