Attaching elements

Step 1: Getting Security Hierarchy in Place

First we need to get the security hierarchy in place. Every element in the tree has an entity token and this entity token is used for determining security for the element. When C1 CMS does security check for a given element, it looks for permissions set on the given element and all its ancestor entity tokens. So it is important that there exists a path from our element entity token to the root of the tree. So we start out by creating an entity token class for our root element:

[SecurityAncestorProvider(typeof(NoAncestorSecurityAncestorProvider))]
public sealed class MyRootEntityToken : EntityToken
{
  public override string Type
  {
    get { return ""; }
  }
  public override string Source
  {
    get { return ""; }
  }
  public override string Id
  {
    get { return "MyRootEntityToken"; }
  }
  public override string Serialize()
  {
    return DoSerialize();
  }
  public static EntityToken Deserialize(string serializedEntityToken)
  {
    return new MyRootEntityToken();
  }
}

The NoAncestorSecurityAncestorProvider value of the SecurityAncestorProvider attribute specifies that elements having the entity token does not have a native parent when determining security. Later in this tutorial we will add a hook from our root element to the Content perspective element, so that it will naturally inherit the security settings from the Content perspective – unless it’s overwritten by a user locally on our root element.