Class AccessControlEntry
Defines an Access Control Entry
Inheritance
Implements
Inherited Members
Namespace: EPiServer.Security
Assembly: EPiServer.dll
Version: 9.12.2Syntax
public class AccessControlEntry : IEquatable<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.
private void SetAccessRights(PageData page)
{
PageData teamStart = Locate.ContentRepository().Get<PageData>(page.ParentLink);
AccessControlList aclClone = page.ACL.CreateWritableClone();
aclClone.IsInherited = false;
aclClone.ClearEntries();
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
aclClone.Add(new AccessControlEntry("PrincipalInfo.Current.Name", AccessLevel.FullAccess));
To get a user as the AccessControlEntry you need to use this instead
aclClone.Add(new AccessControlEntry("PrincipalInfo.Current.Name", AccessLevel.FullAccess, SecurityEntityType.User));
Constructors
AccessControlEntry(RawACE)
Initializes a new instance of the AccessControlEntry class.
Declaration
public AccessControlEntry(RawACE rawAce)
Parameters
Type | Name | Description |
---|---|---|
RawACE | rawAce | The raw ACE. |
Remarks
Will use the AutomaticEntryType to determine if it is a Role or User.
AccessControlEntry(String, AccessLevel)
Initializes a new instance of the AccessControlEntry class.
Declaration
public AccessControlEntry(string name, AccessLevel access)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the role. |
AccessLevel | access | The access level. |
Remarks
Note that this constructor will create the ACE as a Role ACE.
AccessControlEntry(String, AccessLevel, SecurityEntityType)
Initializes a new instance of the AccessControlEntry class.
Declaration
public AccessControlEntry(string name, AccessLevel access, SecurityEntityType entityType)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the user or role. |
AccessLevel | access | The access level. |
SecurityEntityType | entityType | Type of the entity (User or Role). |
Properties
Access
Gets the access level.
Declaration
public AccessLevel Access { get; }
Property Value
Type | Description |
---|---|
AccessLevel | The access level. |
Remarks
The access level for this entry.
EntityType
Gets the type of the entry.
Declaration
public SecurityEntityType EntityType { get; }
Property Value
Type | Description |
---|---|
SecurityEntityType | The type of the entry. |
Remarks
We only support Users or Roles.
Name
Gets the name of the entry for this ACE.
Declaration
public string Name { get; }
Property Value
Type | Description |
---|---|
System.String | The name. |
Remarks
This is the name of a user or a role that this Access Control Entry applies to.
Methods
Equals(AccessControlEntry)
Indicates whether the current AccessControlEntry instance is equal to another AccessControlEntry instance.
Declaration
public virtual bool Equals(AccessControlEntry other)
Parameters
Type | Name | Description |
---|---|---|
AccessControlEntry | other | An AccessControlEntry to compare with this instance. |
Returns
Type | Description |
---|---|
System.Boolean | true if the current instance is equal to the |
IsEqual(AccessControlEntry)
Determines whether the specified entry is equal to this instance. With equal means NameEntityType and Access is same.
Declaration
[Obsolete("Renamed to Equals to match the System.IEquatable<> interface")]
public bool IsEqual(AccessControlEntry entry)
Parameters
Type | Name | Description |
---|---|---|
AccessControlEntry | entry | The entry. |
Returns
Type | Description |
---|---|
System.Boolean |
|