FileSystemAccessRule コンストラクター
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
FileSystemAccessRule クラスの新しいインスタンスを初期化します。
オーバーロード
| 名前 | 説明 |
|---|---|
| FileSystemAccessRule(IdentityReference, FileSystemRights, AccessControlType) |
ユーザー アカウントへの参照、アクセス規則に関連付けられている操作の種類を指定する値、および操作を許可または拒否するかどうかを指定する値を使用して、 FileSystemAccessRule クラスの新しいインスタンスを初期化します。 |
| FileSystemAccessRule(String, FileSystemRights, AccessControlType) |
ユーザー アカウントの名前、アクセス規則に関連付けられている操作の種類を指定する値、および操作を許可または拒否するかどうかを示す値を使用して、 FileSystemAccessRule クラスの新しいインスタンスを初期化します。 |
| FileSystemAccessRule(IdentityReference, FileSystemRights, InheritanceFlags, PropagationFlags, AccessControlType) |
ユーザー アカウントへの参照、アクセス規則に関連付けられている操作の種類を指定する値、権限の継承方法を決定する値、権限の伝達方法を決定する値、操作を許可または拒否するかどうかを指定する値を使用して、 FileSystemAccessRule クラスの新しいインスタンスを初期化します。 |
| FileSystemAccessRule(String, FileSystemRights, InheritanceFlags, PropagationFlags, AccessControlType) |
ユーザー アカウントの名前、アクセス規則に関連付けられている操作の種類を指定する値、権限の継承方法を決定する値、権限の伝達方法を決定する値、操作を許可または拒否するかどうかを指定する値を使用して、 FileSystemAccessRule クラスの新しいインスタンスを初期化します。 |
FileSystemAccessRule(IdentityReference, FileSystemRights, AccessControlType)
ユーザー アカウントへの参照、アクセス規則に関連付けられている操作の種類を指定する値、および操作を許可または拒否するかどうかを指定する値を使用して、 FileSystemAccessRule クラスの新しいインスタンスを初期化します。
public:
FileSystemAccessRule(System::Security::Principal::IdentityReference ^ identity, System::Security::AccessControl::FileSystemRights fileSystemRights, System::Security::AccessControl::AccessControlType type);
public FileSystemAccessRule(System.Security.Principal.IdentityReference identity, System.Security.AccessControl.FileSystemRights fileSystemRights, System.Security.AccessControl.AccessControlType type);
new System.Security.AccessControl.FileSystemAccessRule : System.Security.Principal.IdentityReference * System.Security.AccessControl.FileSystemRights * System.Security.AccessControl.AccessControlType -> System.Security.AccessControl.FileSystemAccessRule
Public Sub New (identity As IdentityReference, fileSystemRights As FileSystemRights, type As AccessControlType)
パラメーター
- identity
- IdentityReference
ユーザー アカウントへの参照をカプセル化する IdentityReference オブジェクト。
- fileSystemRights
- FileSystemRights
アクセス規則に関連付けられている操作の種類を指定する FileSystemRights 値の 1 つ。
- type
- AccessControlType
操作を許可するか拒否するかを指定する AccessControlType 値の 1 つ。
例外
identity パラメーターは、IdentityReference オブジェクトではありません。
identity パラメーターはnull。
正しくない列挙が type パラメーターに渡されました。
注釈
このコンストラクターを使用して、 FileSecurity または DirectorySecurity クラスを使用して永続化できるアクセス制御規則を作成します。 アクセス制御規則は、Microsoft Windowsを実行しているコンピューターで許可または禁止されるアクションを決定するユーザー アカウント権限を定義します。
適用対象
FileSystemAccessRule(String, FileSystemRights, AccessControlType)
ユーザー アカウントの名前、アクセス規則に関連付けられている操作の種類を指定する値、および操作を許可または拒否するかどうかを示す値を使用して、 FileSystemAccessRule クラスの新しいインスタンスを初期化します。
public:
FileSystemAccessRule(System::String ^ identity, System::Security::AccessControl::FileSystemRights fileSystemRights, System::Security::AccessControl::AccessControlType type);
public FileSystemAccessRule(string identity, System.Security.AccessControl.FileSystemRights fileSystemRights, System.Security.AccessControl.AccessControlType type);
new System.Security.AccessControl.FileSystemAccessRule : string * System.Security.AccessControl.FileSystemRights * System.Security.AccessControl.AccessControlType -> System.Security.AccessControl.FileSystemAccessRule
Public Sub New (identity As String, fileSystemRights As FileSystemRights, type As AccessControlType)
パラメーター
- identity
- String
ユーザー アカウントの名前。
- fileSystemRights
- FileSystemRights
アクセス規則に関連付けられている操作の種類を指定する FileSystemRights 値の 1 つ。
- type
- AccessControlType
操作を許可するか拒否するかを指定する AccessControlType 値の 1 つ。
例外
identity パラメーターはnull。
正しくない列挙が type パラメーターに渡されました。
例
次のコード例では、 FileSecurity クラスを使用して、アクセス制御エントリ (ACE) をファイルに追加して削除します。 この例を実行するには、有効なユーザーまたはグループ アカウントを指定する必要があります。
using System;
using System.IO;
using System.Security.AccessControl;
namespace FileSystemExample
{
class FileExample
{
public static void Main()
{
try
{
string fileName = "test.xml";
Console.WriteLine($"Adding access control entry for {fileName}");
// Add the access control entry to the file.
AddFileSecurity(fileName, @"DomainName\AccountName",
FileSystemRights.ReadData, AccessControlType.Allow);
Console.WriteLine($"Removing access control entry from {fileName}");
// Remove the access control entry from the file.
RemoveFileSecurity(fileName, @"DomainName\AccountName",
FileSystemRights.ReadData, AccessControlType.Allow);
Console.WriteLine("Done.");
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
// Adds an ACL entry on the specified file for the specified account.
public static void AddFileSecurity(string fileName, string account,
FileSystemRights rights, AccessControlType controlType)
{
FileInfo fileInfo = new(fileName);
FileSecurity fSecurity = fileInfo.GetAccessControl();
// Add the FileSystemAccessRule to the security settings.
fSecurity.AddAccessRule(new FileSystemAccessRule(account,
rights, controlType));
// Set the new access settings.
fileInfo.SetAccessControl(fSecurity);
}
// Removes an ACL entry on the specified file for the specified account.
public static void RemoveFileSecurity(string fileName, string account,
FileSystemRights rights, AccessControlType controlType)
{
FileInfo fileInfo = new(fileName);
FileSecurity fSecurity = fileInfo.GetAccessControl();
// Remove the FileSystemAccessRule from the security settings.
fSecurity.RemoveAccessRule(new FileSystemAccessRule(account,
rights, controlType));
// Set the new access settings.
fileInfo.SetAccessControl(fSecurity);
}
}
}
Imports System.IO
Imports System.Security.AccessControl
Module FileExample
Sub Main()
Try
Dim fileName As String = "test.xml"
Console.WriteLine("Adding access control entry for " & fileName)
' Add the access control entry to the file.
AddFileSecurity(fileName, "DomainName\AccountName",
FileSystemRights.ReadData, AccessControlType.Allow)
Console.WriteLine("Removing access control entry from " & fileName)
' Remove the access control entry from the file.
RemoveFileSecurity(fileName, "DomainName\AccountName",
FileSystemRights.ReadData, AccessControlType.Allow)
Console.WriteLine("Done.")
Catch e As Exception
Console.WriteLine(e)
End Try
End Sub
' Adds an ACL entry on the specified file for the specified account.
Sub AddFileSecurity(ByVal fileName As String, ByVal account As String,
ByVal rights As FileSystemRights, ByVal controlType As AccessControlType)
Dim fileInfo As New FileInfo(fileName)
Dim fSecurity As FileSecurity = fileInfo.GetAccessControl()
' Add the FileSystemAccessRule to the security settings.
Dim accessRule As New FileSystemAccessRule(account, rights, controlType)
fSecurity.AddAccessRule(accessRule)
' Set the new access settings.
fileInfo.SetAccessControl(fSecurity)
End Sub
' Removes an ACL entry on the specified file for the specified account.
Sub RemoveFileSecurity(ByVal fileName As String, ByVal account As String,
ByVal rights As FileSystemRights, ByVal controlType As AccessControlType)
Dim fileInfo As New FileInfo(fileName)
Dim fSecurity As FileSecurity = fileInfo.GetAccessControl()
' Remove the FileSystemAccessRule from the security settings.
fSecurity.RemoveAccessRule(New FileSystemAccessRule(account,
rights, controlType))
' Set the new access settings.
fileInfo.SetAccessControl(fSecurity)
End Sub
End Module
注釈
このコンストラクターを使用して、 FileSecurity または DirectorySecurity クラスを使用して永続化できるアクセス制御規則を作成します。 アクセス制御規則は、Microsoft Windowsを実行しているコンピューターで許可または禁止されるアクションを決定するユーザー アカウント権限を定義します。
identity パラメーターは、現在のコンピューターまたはドメイン上の有効なアカウントを識別する必要があります。 文字列は次の形式になります。ここで、 DOMAIN は有効なドメインまたはコンピューター名の名前、 account はドメインまたはコンピューター上の有効なユーザー アカウントの名前です: DOMAIN\account。
適用対象
FileSystemAccessRule(IdentityReference, FileSystemRights, InheritanceFlags, PropagationFlags, AccessControlType)
ユーザー アカウントへの参照、アクセス規則に関連付けられている操作の種類を指定する値、権限の継承方法を決定する値、権限の伝達方法を決定する値、操作を許可または拒否するかどうかを指定する値を使用して、 FileSystemAccessRule クラスの新しいインスタンスを初期化します。
public:
FileSystemAccessRule(System::Security::Principal::IdentityReference ^ identity, System::Security::AccessControl::FileSystemRights fileSystemRights, System::Security::AccessControl::InheritanceFlags inheritanceFlags, System::Security::AccessControl::PropagationFlags propagationFlags, System::Security::AccessControl::AccessControlType type);
public FileSystemAccessRule(System.Security.Principal.IdentityReference identity, System.Security.AccessControl.FileSystemRights fileSystemRights, System.Security.AccessControl.InheritanceFlags inheritanceFlags, System.Security.AccessControl.PropagationFlags propagationFlags, System.Security.AccessControl.AccessControlType type);
new System.Security.AccessControl.FileSystemAccessRule : System.Security.Principal.IdentityReference * System.Security.AccessControl.FileSystemRights * System.Security.AccessControl.InheritanceFlags * System.Security.AccessControl.PropagationFlags * System.Security.AccessControl.AccessControlType -> System.Security.AccessControl.FileSystemAccessRule
Public Sub New (identity As IdentityReference, fileSystemRights As FileSystemRights, inheritanceFlags As InheritanceFlags, propagationFlags As PropagationFlags, type As AccessControlType)
パラメーター
- identity
- IdentityReference
ユーザー アカウントへの参照をカプセル化する IdentityReference オブジェクト。
- fileSystemRights
- FileSystemRights
アクセス規則に関連付けられている操作の種類を指定する FileSystemRights 値の 1 つ。
- inheritanceFlags
- InheritanceFlags
アクセス マスクを子オブジェクトに伝達する方法を指定する InheritanceFlags 値の 1 つ。
- propagationFlags
- PropagationFlags
Access Control エントリ (ACE) を子オブジェクトに伝達する方法を指定する PropagationFlags 値の 1 つ。
- type
- AccessControlType
操作を許可するか拒否するかを指定する AccessControlType 値の 1 つ。
例外
identity パラメーターは、IdentityReference オブジェクトではありません。
identity パラメーターはnull。
正しくない列挙が type パラメーターに渡されました。
-又は-
正しくない列挙が inheritanceFlags パラメーターに渡されました。
-又は-
正しくない列挙が propagationFlags パラメーターに渡されました。
注釈
このコンストラクターを使用して、 FileSecurity または DirectorySecurity クラスを使用して永続化できるアクセス制御規則を作成します。 アクセス制御規則は、Microsoft Windowsを実行しているコンピューターで許可または禁止されるアクションを決定するユーザー アカウント権限を定義します。
適用対象
FileSystemAccessRule(String, FileSystemRights, InheritanceFlags, PropagationFlags, AccessControlType)
ユーザー アカウントの名前、アクセス規則に関連付けられている操作の種類を指定する値、権限の継承方法を決定する値、権限の伝達方法を決定する値、操作を許可または拒否するかどうかを指定する値を使用して、 FileSystemAccessRule クラスの新しいインスタンスを初期化します。
public:
FileSystemAccessRule(System::String ^ identity, System::Security::AccessControl::FileSystemRights fileSystemRights, System::Security::AccessControl::InheritanceFlags inheritanceFlags, System::Security::AccessControl::PropagationFlags propagationFlags, System::Security::AccessControl::AccessControlType type);
public FileSystemAccessRule(string identity, System.Security.AccessControl.FileSystemRights fileSystemRights, System.Security.AccessControl.InheritanceFlags inheritanceFlags, System.Security.AccessControl.PropagationFlags propagationFlags, System.Security.AccessControl.AccessControlType type);
new System.Security.AccessControl.FileSystemAccessRule : string * System.Security.AccessControl.FileSystemRights * System.Security.AccessControl.InheritanceFlags * System.Security.AccessControl.PropagationFlags * System.Security.AccessControl.AccessControlType -> System.Security.AccessControl.FileSystemAccessRule
Public Sub New (identity As String, fileSystemRights As FileSystemRights, inheritanceFlags As InheritanceFlags, propagationFlags As PropagationFlags, type As AccessControlType)
パラメーター
- identity
- String
ユーザー アカウントの名前。
- fileSystemRights
- FileSystemRights
アクセス規則に関連付けられている操作の種類を指定する FileSystemRights 値の 1 つ。
- inheritanceFlags
- InheritanceFlags
アクセス マスクを子オブジェクトに伝達する方法を指定する InheritanceFlags 値の 1 つ。
- propagationFlags
- PropagationFlags
Access Control エントリ (ACE) を子オブジェクトに伝達する方法を指定する PropagationFlags 値の 1 つ。
- type
- AccessControlType
操作を許可するか拒否するかを指定する AccessControlType 値の 1 つ。
例外
identity パラメーターはnull。
正しくない列挙が type パラメーターに渡されました。
-又は-
正しくない列挙が inheritanceFlags パラメーターに渡されました。
-又は-
正しくない列挙が propagationFlags パラメーターに渡されました。
注釈
このコンストラクターを使用して、 FileSecurity または DirectorySecurity クラスを使用して永続化できるアクセス制御規則を作成します。 アクセス制御規則は、Microsoft Windowsを実行しているコンピューターで許可または禁止されるアクションを決定するユーザー アカウント権限を定義します。
identity パラメーターは、現在のコンピューターまたはドメイン上の有効なアカウントを識別する必要があります。 文字列は次の形式になります。ここで、 DOMAIN は有効なドメインまたはコンピューター名の名前、 account はドメインまたはコンピューター上の有効なユーザー アカウントの名前です: DOMAIN\account。