FileSystemRights Wyliczenie
Definicja
Ważne
Niektóre informacje odnoszą się do produktu w wersji wstępnej, który może zostać znacząco zmodyfikowany przed wydaniem. Firma Microsoft nie udziela żadnych gwarancji, jawnych lub domniemanych, w odniesieniu do informacji podanych w tym miejscu.
Definiuje prawa dostępu do użycia podczas tworzenia reguł dostępu i inspekcji.
To wyliczenie obsługuje bitową kombinację jego wartości składowych.
public enum class FileSystemRights
[System.Flags]
public enum FileSystemRights
[System.Flags]
[System.Security.SecurityCritical]
public enum FileSystemRights
[<System.Flags>]
type FileSystemRights =
[<System.Flags>]
[<System.Security.SecurityCritical>]
type FileSystemRights =
Public Enum FileSystemRights
- Dziedziczenie
- Atrybuty
Pola
AppendData | 4 | Określa prawo do dołączania danych na końcu pliku. |
ChangePermissions | 262144 | Określa prawo do zmiany reguł zabezpieczeń i inspekcji skojarzonych z plikiem lub folderem. |
CreateDirectories | 4 | Określa prawo do utworzenia folderu To prawo wymaga |
CreateFiles | 2 | Określa prawo do utworzenia pliku. To prawo wymaga |
Delete | 65536 | Określa prawo do usunięcia folderu lub pliku. |
DeleteSubdirectoriesAndFiles | 64 | Określa prawo do usunięcia folderu i wszystkich plików zawartych w tym folderze. |
ExecuteFile | 32 | Określa prawo do uruchomienia pliku aplikacji. |
FullControl | 2032127 | Określa prawo do wywierania pełnej kontroli nad folderem lub plikiem oraz modyfikowania reguł kontroli dostępu i inspekcji. Ta wartość reprezentuje prawo do wykonania wszystkich czynności z plikiem i jest kombinacją wszystkich praw w tym wyliczeniem. |
ListDirectory | 1 | Określa prawo do odczytania zawartości katalogu. |
Modify | 197055 | Określa prawo do odczytu, zapisu, wyświetlania listy zawartości folderu, usuwania folderów i plików oraz uruchamiania plików aplikacji. To prawo obejmuje ReadAndExecute prawo, Write prawo i Delete prawo. |
Read | 131209 | Określa prawo do otwierania i kopiowania folderów lub plików jako tylko do odczytu. To prawo obejmuje ReadData prawo, ReadExtendedAttributes prawo, ReadAttributes prawo i ReadPermissions prawo. |
ReadAndExecute | 131241 | Określa prawo do otwierania i kopiowania folderów lub plików jako tylko do odczytu oraz uruchamiania plików aplikacji. To prawo obejmuje Read prawo i ExecuteFile prawo. |
ReadAttributes | 128 | Określa prawo do otwierania i kopiowania atrybutów systemu plików z folderu lub pliku. Na przykład ta wartość określa prawo do wyświetlenia daty utworzenia lub modyfikacji pliku. Nie obejmuje to prawa do odczytu danych, rozszerzonych atrybutów systemu plików ani reguł dostępu i inspekcji. |
ReadData | 1 | Określa prawo do otwierania i kopiowania pliku lub folderu. Nie obejmuje to prawa do odczytywania atrybutów systemu plików, rozszerzonych atrybutów systemu plików ani reguł dostępu i inspekcji. |
ReadExtendedAttributes | 8 | Określa prawo do otwierania i kopiowania rozszerzonych atrybutów systemu plików z folderu lub pliku. Na przykład ta wartość określa prawo do wyświetlania informacji o autorze i zawartości. Nie obejmuje to prawa do odczytu danych, atrybutów systemu plików ani reguł dostępu i inspekcji. |
ReadPermissions | 131072 | Określa prawo do otwierania i kopiowania reguł dostępu i inspekcji z folderu lub pliku. Nie obejmuje to prawa do odczytu danych, atrybutów systemu plików i rozszerzonych atrybutów systemu plików. |
Synchronize | 1048576 | Określa, czy aplikacja może poczekać na synchronizację uchwytu pliku z ukończeniem operacji we/wy. Ta wartość jest ustawiana automatycznie podczas zezwalania na dostęp i automatycznego wykluczania podczas odmowy dostępu. |
TakeOwnership | 524288 | Określa prawo do zmiany właściciela folderu lub pliku. Należy pamiętać, że właściciele zasobu mają pełny dostęp do tego zasobu. |
Traverse | 32 | Określa prawo do wyświetlania listy zawartości folderu i uruchamiania aplikacji zawartych w tym folderze. |
Write | 278 | Określa prawo do tworzenia folderów i plików oraz dodawania lub usuwania danych z plików. To prawo obejmuje WriteData prawo, AppendData prawo, WriteExtendedAttributes prawo i WriteAttributes prawo. |
WriteAttributes | 256 | Określa prawo do otwierania i zapisywania atrybutów systemu plików w folderze lub pliku. Nie obejmuje to możliwości zapisu danych, atrybutów rozszerzonych ani reguł dostępu i inspekcji. |
WriteData | 2 | Określa prawo do otwierania i zapisywania w pliku lub folderze. Nie obejmuje to prawa do otwierania i zapisywania atrybutów systemu plików, rozszerzonych atrybutów systemu plików ani reguł dostępu i inspekcji. |
WriteExtendedAttributes | 16 | Określa prawo do otwierania i zapisywania rozszerzonych atrybutów systemu plików do folderu lub pliku. Nie obejmuje to możliwości zapisu danych, atrybutów ani reguł dostępu i inspekcji. |
Przykłady
W poniższym przykładzie użyto wyliczenia FileSystemRights
, aby określić regułę dostępu, a następnie usunąć regułę dostępu z pliku. Aby uruchomić ten przykład, musisz podać prawidłowe konto użytkownika lub grupy.
using namespace System;
using namespace System::IO;
using namespace System::Security::AccessControl;
// Adds an ACL entry on the specified file for the specified account.
void AddFileSecurity(String^ fileName, String^ account,
FileSystemRights rights, AccessControlType controlType)
{
// Get a FileSecurity object that represents the
// current security settings.
FileSecurity^ fSecurity = File::GetAccessControl(fileName);
// Add the FileSystemAccessRule to the security settings.
fSecurity->AddAccessRule(gcnew FileSystemAccessRule
(account,rights, controlType));
// Set the new access settings.
File::SetAccessControl(fileName, fSecurity);
}
// Removes an ACL entry on the specified file for the specified account.
void RemoveFileSecurity(String^ fileName, String^ account,
FileSystemRights rights, AccessControlType controlType)
{
// Get a FileSecurity object that represents the
// current security settings.
FileSecurity^ fSecurity = File::GetAccessControl(fileName);
// Remove the FileSystemAccessRule from the security settings.
fSecurity->RemoveAccessRule(gcnew FileSystemAccessRule
(account,rights, controlType));
// Set the new access settings.
File::SetAccessControl(fileName, fSecurity);
}
int main()
{
try
{
String^ fileName = "test.xml";
Console::WriteLine("Adding access control entry for " + fileName);
// Add the access control entry to the file.
AddFileSecurity(fileName, "MYDOMAIN\\MyAccount",
FileSystemRights::ReadData, AccessControlType::Allow);
Console::WriteLine("Removing access control entry from " + fileName);
// Remove the access control entry from the file.
RemoveFileSecurity(fileName, "MYDOMAIN\\MyAccount",
FileSystemRights::ReadData, AccessControlType::Allow);
Console::WriteLine("Done.");
}
catch (Exception^ ex)
{
Console::WriteLine(ex->Message);
}
}
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)
{
// Get a FileSecurity object that represents the
// current security settings.
FileSecurity fSecurity = File.GetAccessControl(fileName);
// Add the FileSystemAccessRule to the security settings.
fSecurity.AddAccessRule(new FileSystemAccessRule(account,
rights, controlType));
// Set the new access settings.
File.SetAccessControl(fileName, 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)
{
// Get a FileSecurity object that represents the
// current security settings.
FileSecurity fSecurity = File.GetAccessControl(fileName);
// Remove the FileSystemAccessRule from the security settings.
fSecurity.RemoveAccessRule(new FileSystemAccessRule(account,
rights, controlType));
// Set the new access settings.
File.SetAccessControl(fileName, 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)
' Get a FileSecurity object that represents the
' current security settings.
Dim fSecurity As FileSecurity = File.GetAccessControl(fileName)
' Add the FileSystemAccessRule to the security settings.
Dim accessRule As FileSystemAccessRule = _
New FileSystemAccessRule(account, rights, controlType)
fSecurity.AddAccessRule(accessRule)
' Set the new access settings.
File.SetAccessControl(fileName, 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)
' Get a FileSecurity object that represents the
' current security settings.
Dim fSecurity As FileSecurity = File.GetAccessControl(fileName)
' Remove the FileSystemAccessRule from the security settings.
fSecurity.RemoveAccessRule(New FileSystemAccessRule(account, _
rights, controlType))
' Set the new access settings.
File.SetAccessControl(fileName, fSecurity)
End Sub
End Module
Uwagi
Wyliczenie FileSystemRights określa, które akcje systemu plików są dozwolone dla określonego konta użytkownika i które akcje systemu plików są poddawane inspekcji dla określonego konta użytkownika.
Użyj wyliczenia FileSystemRights podczas tworzenia reguły dostępu z FileSystemAccessRule klasą lub podczas tworzenia reguły inspekcji z klasą FileSystemAuditRule .
Ta wyliczenie zawiera kilka szczegółowych wartości praw systemowych i kilka wartości, które są kombinacją tych szczegółowych wartości. Łatwiej jest używać wartości kombinacji, takich jak FullControl
, Read
i Write
, zamiast osobno określać każdą wartość składnika.
Prawa CreateDirectories
i CreateFiles
wymagają Synchronize
prawa. Jeśli nie ustawisz Synchronize
jawnie wartości podczas tworzenia pliku lub katalogu, zostanie ona ustawiona automatycznie.
Dotyczy
Opinia
https://aka.ms/ContentUserFeedback.
Dostępne już wkrótce: W 2024 r. będziemy stopniowo wycofywać zgłoszenia z serwisu GitHub jako mechanizm przesyłania opinii na temat zawartości i zastępować go nowym systemem opinii. Aby uzyskać więcej informacji, sprawdź:Prześlij i wyświetl opinię dla