Rights Summary

Rights Summary

Controls featured in this example:

  • Sitecore Web Control

Classes featured in this example:

  • Sitecore.Context
  • Sitecore.Data.Items.Item
  • Sitecore.Security.AccessControl.AccessRight

C# Web Control Code

Sitecore.Data.Items.Item item = Sitecore.Context.Item;
if (item == null) return;

Sitecore.Security.AccessControl.AccessRight[] accessRights = new Sitecore.Security.AccessControl.AccessRight[15];
if (accessRights == null) return;

accessRights[0] = Sitecore.Security.AccessControl.AccessRight.FieldRead;
accessRights[1] = Sitecore.Security.AccessControl.AccessRight.FieldWrite;
accessRights[2] = Sitecore.Security.AccessControl.AccessRight.InsertShow;
accessRights[3] = Sitecore.Security.AccessControl.AccessRight.ItemAdmin;
accessRights[4] = Sitecore.Security.AccessControl.AccessRight.ItemCreate;
accessRights[5] = Sitecore.Security.AccessControl.AccessRight.ItemDelete;
accessRights[6] = Sitecore.Security.AccessControl.AccessRight.ItemRead;
accessRights[7] = Sitecore.Security.AccessControl.AccessRight.ItemRename;
accessRights[8] = Sitecore.Security.AccessControl.AccessRight.ItemWrite;
accessRights[9] = Sitecore.Security.AccessControl.AccessRight.LanguageRead;
accessRights[10] = Sitecore.Security.AccessControl.AccessRight.LanguageWrite;
accessRights[11] = Sitecore.Security.AccessControl.AccessRight.SiteEnter;
accessRights[12] = Sitecore.Security.AccessControl.AccessRight.WorkflowCommandExecute;
accessRights[13] = Sitecore.Security.AccessControl.AccessRight.WorkflowStateDelete;
accessRights[14] = Sitecore.Security.AccessControl.AccessRight.WorkflowStateWrite;

output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold; width:100%; clear:both");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Div);
output.Write("C# Web Control Real-time Output");
output.RenderEndTag();

output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-size:x-small; width:100%; clear:both");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Div);
output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-weight:bold");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.P);
string itemName = Sitecore.StringUtil.GetString(item.DisplayName, item.Name);
//using : for colon and   for space
output.Write("{0}", "Access " + itemName);
output.RenderEndTag(); //P

output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Align, "center");
output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Border, "0");
output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Cellpadding, "2");
output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Style, "font-size:small");
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Table);
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Thead);
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Th);
output.Write("Name");
output.RenderEndTag(); //Th

output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Th);
output.Write("Modifies Data");
output.RenderEndTag(); //Th

output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Th);
output.Write("Field Right");
output.RenderEndTag(); //Th

output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Th);
output.Write("Item Right");
output.RenderEndTag(); //Th

output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Th);
output.Write("Language Right");
output.RenderEndTag(); //Th

output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Th);
output.Write("Site Right");
output.RenderEndTag(); //Th

output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Th);
output.Write("WF Command Right");
output.RenderEndTag(); //Th

output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Th);
output.Write("WF State Right");
output.RenderEndTag(); //Th
output.RenderEndTag(); //Thead
output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Tbody);

for(int i = 0; i < accessRights.GetLength(0); i++) 
{
    output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Tr);
    output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Td);
    output.Write("{0}", accessRights[i].Title);
    output.RenderEndTag(); //Td
    
    output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Align, "center");
    output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Td);
    if (accessRights[i].ModifiesData)
        output.Write("{0}", "&#9746;");
    else
        output.Write("{0}", "&#9744;");
    output.RenderEndTag(); //Td

    output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Align, "center");
    output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Td);
    if (accessRights[i].IsFieldRight)
        output.Write("{0}", "&#9746;");
    else
        output.Write("{0}", "&#9744;");
    output.RenderEndTag(); //Td

    output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Align, "center");
    output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Td);
    if (accessRights[i].IsItemRight)
        output.Write("{0}", "&#9746;");
    else
        output.Write("{0}", "&#9744;");
    output.RenderEndTag(); //Td

    output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Align, "center");
    output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Td);
    if (accessRights[i].IsLanguageRight)
        output.Write("{0}", "&#9746;");
    else
        output.Write("{0}", "&#9744;");
    output.RenderEndTag(); //Td

    output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Align, "center");
    output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Td);
    if (accessRights[i].IsSiteRight)
        output.Write("{0}", "&#9746;");
    else
        output.Write("{0}", "&#9744;");
    output.RenderEndTag(); //Td

    output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Align, "center");
    output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Td);
    if (accessRights[i].IsWorkflowCommandRight)
        output.Write("{0}", "&#9746;");
    else
        output.Write("{0}", "&#9744;");
    output.RenderEndTag(); //Td

    output.AddAttribute(System.Web.UI.HtmlTextWriterAttribute.Align, "center");
    output.RenderBeginTag(System.Web.UI.HtmlTextWriterTag.Td);
    if (accessRights[i].IsWorkflowStateRight)
        output.Write("{0}", "&#9746;");
    else
        output.Write("{0}", "&#9744;");
    output.RenderEndTag(); //Td
    output.RenderEndTag(); //Tr
}
output.RenderEndTag(); //Tbody
output.RenderEndTag(); //Table
output.RenderEndTag(); //Div


C# Web Control Real-time Output

Access Rights Summary

Name Modifies Data Field Right Item Right Language Right Site Right WF Command Right WF State Right
Field Read
Field Write
Show in Insert
Administer
Create
Delete
Read
Rename
Write
Language Read
Language Write
Site Enter
Workflow Command Execute
Workflow State Delete
Workflow State Write