mscorlib(4.0.0.0) API with additions
FileSystemAccessRule.cs
2 
4 {
6  public sealed class FileSystemAccessRule : AccessRule
7  {
10  public FileSystemRights FileSystemRights => RightsFromAccessMask(base.AccessMask);
11 
20  : this(identity, AccessMaskFromRights(fileSystemRights, type), isInherited: false, InheritanceFlags.None, PropagationFlags.None, type)
21  {
22  }
23 
30  public FileSystemAccessRule(string identity, FileSystemRights fileSystemRights, AccessControlType type)
31  : this(new NTAccount(identity), AccessMaskFromRights(fileSystemRights, type), isInherited: false, InheritanceFlags.None, PropagationFlags.None, type)
32  {
33  }
34 
44  public FileSystemAccessRule(IdentityReference identity, FileSystemRights fileSystemRights, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, AccessControlType type)
45  : this(identity, AccessMaskFromRights(fileSystemRights, type), isInherited: false, inheritanceFlags, propagationFlags, type)
46  {
47  }
48 
57  public FileSystemAccessRule(string identity, FileSystemRights fileSystemRights, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, AccessControlType type)
58  : this(new NTAccount(identity), AccessMaskFromRights(fileSystemRights, type), isInherited: false, inheritanceFlags, propagationFlags, type)
59  {
60  }
61 
62  internal FileSystemAccessRule(IdentityReference identity, int accessMask, bool isInherited, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, AccessControlType type)
63  : base(identity, accessMask, isInherited, inheritanceFlags, propagationFlags, type)
64  {
65  }
66 
67  internal static int AccessMaskFromRights(FileSystemRights fileSystemRights, AccessControlType controlType)
68  {
69  if (fileSystemRights < (FileSystemRights)0 || fileSystemRights > FileSystemRights.FullControl)
70  {
71  throw new ArgumentOutOfRangeException("fileSystemRights", Environment.GetResourceString("Argument_InvalidEnumValue", fileSystemRights, "FileSystemRights"));
72  }
73  switch (controlType)
74  {
75  case AccessControlType.Allow:
76  fileSystemRights |= FileSystemRights.Synchronize;
77  break;
78  case AccessControlType.Deny:
79  if (fileSystemRights != FileSystemRights.FullControl && fileSystemRights != (FileSystemRights.ReadData | FileSystemRights.WriteData | FileSystemRights.AppendData | FileSystemRights.ReadExtendedAttributes | FileSystemRights.WriteExtendedAttributes | FileSystemRights.ExecuteFile | FileSystemRights.ReadAttributes | FileSystemRights.WriteAttributes | FileSystemRights.Delete | FileSystemRights.ReadPermissions | FileSystemRights.ChangePermissions | FileSystemRights.TakeOwnership | FileSystemRights.Synchronize))
80  {
81  fileSystemRights &= ~FileSystemRights.Synchronize;
82  }
83  break;
84  }
85  return (int)fileSystemRights;
86  }
87 
88  internal static FileSystemRights RightsFromAccessMask(int accessMask)
89  {
90  return (FileSystemRights)accessMask;
91  }
92  }
93 }
FileSystemAccessRule(string identity, FileSystemRights fileSystemRights, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, AccessControlType type)
Initializes a new instance of the T:System.Security.AccessControl.FileSystemAccessRule class using th...
FileSystemRights
Defines the access rights to use when creating access and audit rules.
PropagationFlags
Specifies how Access Control Entries (ACEs) are propagated to child objects. These flags are signific...
FileSystemAccessRule(IdentityReference identity, FileSystemRights fileSystemRights, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, AccessControlType type)
Initializes a new instance of the T:System.Security.AccessControl.FileSystemAccessRule class using a ...
FileSystemAccessRule(string identity, FileSystemRights fileSystemRights, AccessControlType type)
Initializes a new instance of the T:System.Security.AccessControl.FileSystemAccessRule class using th...
FileSystemRights FileSystemRights
Gets the T:System.Security.AccessControl.FileSystemRights flags associated with the current T:System....
Represents an identity and is the base class for the T:System.Security.Principal.NTAccount and T:Syst...
Represents a combination of a user's identity, an access mask, and an access control type (allow or d...
Definition: AccessRule.cs:7
Definition: __Canon.cs:3
The exception that is thrown when the value of an argument is outside the allowable range of values a...
Represents a user or group account.
Definition: NTAccount.cs:10
Provides information about, and means to manipulate, the current environment and platform....
Definition: Environment.cs:21
Represents an abstraction of an access control entry (ACE) that defines an access rule for a file or ...
AccessControlType
Specifies whether an T:System.Security.AccessControl.AccessRule object is used to allow or deny acces...
FileSystemAccessRule(IdentityReference identity, FileSystemRights fileSystemRights, AccessControlType type)
Initializes a new instance of the T:System.Security.AccessControl.FileSystemAccessRule class using a ...
AccessControlType AccessControlType
Gets the T:System.Security.AccessControl.AccessControlType value associated with this T:System....
Definition: AccessRule.cs:65
InheritanceFlags
Inheritance flags specify the semantics of inheritance for access control entries (ACEs).