Defines an Access Control Entry

Namespace:  EPiServer.Security
Assembly:  EPiServer (in EPiServer.dll) Version: 6.0.530.0

Syntax

C#
[SerializableAttribute]
public class AccessControlEntry

Examples

The code example below demonstrates the usage of AccessControlList, RawACE and AccessControlEntry. The example below sets up access rights on a "personal" start page. Administrators gets full access, the creator gets everything except for administer and any other user/group that has at least read access on the team start page gets read access rights. page is the page to update the access rights on.
CopyC#
private void SetAccessRights(PageData page)
{
    PageData teamStart = DataFactory.Instance.GetPage(page.ParentLink);

    AccessControlList aclClone = page.ACL.CreateWritableClone();
    aclClone.Clear();

    foreach (RawACE ace in teamStart.ACL.ToRawACEArray())
    {
        if ((ace.Access & AccessLevel.Read) == AccessLevel.Read && ace.Name != PrincipalInfo.Current.Name && ace.Name != "Administrators")
        {
            aclClone.Add(new AccessControlEntry(ace.Name, AccessLevel.Read, ace.AutomaticEntryType));

        }
    }
    aclClone.Add(new AccessControlEntry("Administrators", AccessLevel.FullAccess, SecurityEntityType.Role));
    aclClone.Add(new AccessControlEntry(PrincipalInfo.Current.Name, AccessLevel.FullAccess & ~AccessLevel.Administer, SecurityEntityType.User));
    aclClone.Save(SecuritySaveType.Replace);
}
To get a role with the PrincipalInfo.Current.Name see example below
CopyC#
aclClone.Add(new AccessControlEntry("PrincipalInfo.Current.Name", AccessLevel.FullAccess));
To get a user as the AccessControlEntry you need to use this instead
CopyC#
aclClone.Add(new AccessControlEntry("PrincipalInfo.Current.Name", AccessLevel.FullAccess, SecurityEntityType.User));

Inheritance Hierarchy

System..::.Object
  EPiServer.Security..::.AccessControlEntry

See Also