Ensuring roles in Sitecore

Roles are easy to create in Sitecore but sometimes you might want to ensure that some specific roles always exists. Not a very common scenario but nonetheless it happens. Once upon a time we needed to be able to ensure that a long list of specific roles always existed on the production instance otherwise some of our code and an integration to an external system could fail. Inspired by the EnsureAnonymousUsers processor in the initialize pipeline I made the following small module. It is very similar to the code I shown in my previous post on how to disable the admin user. ...

October 30, 2013 · 2 min · alc

Lucene: Indexing DateTime from Sitecore and querying date ranges

The title should be self explanatory. I need to index some sitecore items that represent some entities that are valid to the public between certain dates. The sitecore fields are date time fields looking like this. I needed a solution for indexing these values in a way that i can do range queries on them. I used the UnixTimeStamp for converting the DateTime field in a UnixTimeStamp field. public static string ConvertToUnixTimeStamp(DateTime value) { var date = new DateTime(1970, 1, 1, 0, 0, 0, value.Kind); var unixTimestamp = Convert.ToInt64((value - date).TotalSeconds); return unixTimestamp.ToString(CultureInfo.InvariantCulture); } Decoding UnixTimeStamp to DateTime : ...

October 29, 2013 · 1 min · ap
Sitecore admin

Disable the Sitecore admin user

A basic Sitecore 1-0-1 security check is to see if the admin account still uses the standard password. It is commonly seen that sites go into production with the admin / b still working. A way to ensure this does not occur is simply to disable the admin account when building to release or other public facing configurations. Disable Sitecore admin user We first create a setting for toggling if the admin user should be disabled. ...

October 29, 2013 · 2 min · alc
crunchpng

Crush png in Sitecore

This post describes a module to crush png in Sitecore which can be downloaded from Sitecore MarketPlace and the latest version of the code is also available free on github. Continuing my fight with Google Page Speed. .NET does not offer an approach for compressing png files other than the default compression. This makes it hard to please google page speed automatically since one of their checks is if the images on a site are losslessly compressed. ...

October 26, 2013 · 6 min · alc

Creating a custom pipeline in Sitecore

Pipelines are one of the most essential parts of Sitecore and creating your own custom pipeline in Sitecore makes your code extremely flexible for both you and others. It is extremely easy to create and run a custom pipeline as this post will show. Defining the pipeline A pipeline consist is a set of processor classes which each has a method called Process which takes one argument of PipelineArgs or a derived class. ...

October 25, 2013 · 1 min · alc

Changing a PDF on the fly using Sitecore Media Request

Some time ago I had a fun challenge for a customer. They wanted a legal notice pdf to be appended to all PDF files which was downloaded from specific parts of the media library on the fly. They also wanted to be able to update the legal notice pdf and use a different one for different parts of the media library. The same concept could also be used for adding a watermark to a pdf or maybe removing all above the first three pages for non-authenticated users etc. ...

October 23, 2013 · 3 min · alc

Preview deletes the .aspxauth cookie

I’ve been working a bit on an extremely weird support case the last couple of days. When the editors on a site clicked on preview from either the content editor or the page editor then the page ended up in a redirect loop. Who stole my cookie? Using Fiddler I quickly noticed that the .ASPXAUTH cookie was removed from the session as soon as preview was clicked and what actually happened was the user being redirected infinitely to the login page until the browser crashed (chrome crashes nice, IE just fails miserably). ...

October 23, 2013 · 2 min · alc

Creating a customHandler in Sitecore

Sometimes you would like all requests to a specific path and below to be handled by a specific generic handler. For example in the same manner as the mediaHandler works in Sitecore. Setting up a customHandler in Sitecore Configuring a normal httpHandler in .NET is easy, you simply add entries in the web.config depending on your version of IIS. Under /configuration/system.webServer/handlers ( for IIS 7 and above) <add verb="*" path="examplehandler.ashx" type="[NAMESPACE].ExampleHandler, [ASSEMBLY]" name="ExampleHandler" /> and the same under /configuration/system.web/httpHandlers (for older versions of IIS) ...

October 22, 2013 · 2 min · alc

How to hijack Sitecore instance using only cookie information

Or how to scare any project manager, sales guy or customer into choosing to run their site on https. This is not going to be a lesson in how to obtain cookie information sent over a network. You can find a ton of youtube videos and other resources on how to setup a tool like cain and abel to do this in minutes. This post is not really about Sitecore either, the example just shows a Sitecore site, ...

October 17, 2013 · 4 min · alc

Inheriting renderings in Sitecore

A typical page layout contains an aside column beside the main content. These aside columns typically contain spots, boxes or whatever you will call them. We call them spots at Pentia. What is the problem then? When using the page editor for inserting and personalizing renderings then there is a 1 - 1 relation with the rendering reference that is inserted and the item. Inserting aside spots on each and every page is extremely time consuming for editors and might also exceed their Sitecore knowledge if they’re not trained. ...

October 15, 2013 · 5 min · alc