FileSystemRights Sabit listesi

Tanım

Erişim ve denetim kuralları oluştururken kullanılacak erişim haklarını tanımlar.

Bu sabit listesi, üyeleri için bit düzeyinde karşılaştırmayı destekler.

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
Devralma
FileSystemRights
Öznitelikler

Alanlar

AppendData 4

Dosyanın sonuna veri ekleme hakkını belirtir.

ChangePermissions 262144

Bir dosya veya klasörle ilişkili güvenlik ve denetim kurallarını değiştirme hakkını belirtir.

CreateDirectories 4

Klasör oluşturma hakkını belirtir Bu hak Eşitle değerini gerektirir.

CreateFiles 2

Dosya oluşturma hakkını belirtir. Bu hak , Eşitle değerini gerektirir.

Delete 65536

Bir klasörü veya dosyayı silme hakkını belirtir.

DeleteSubdirectoriesAndFiles 64

Bir klasörü ve bu klasörün içindeki tüm dosyaları silme hakkını belirtir.

ExecuteFile 32

Uygulama dosyasını çalıştırma hakkını belirtir.

FullControl 2032127

Bir klasör veya dosya üzerinde tam denetim kullanma ve erişim denetimi ile denetim kurallarını değiştirme hakkını belirtir. Bu değer, bir dosyayla herhangi bir şey yapma hakkını temsil eder ve bu numaralandırmadaki tüm hakların birleşimidir.

ListDirectory 1

Bir dizinin içeriğini okuma hakkını belirtir.

Modify 197055

Klasör içeriğini okuma, yazma, listeleme, klasör ve dosyaları silme ve uygulama dosyalarını çalıştırma hakkını belirtir. Bu hak, hakkı, Write hakkı ve Delete hakkı içerirReadAndExecute.

Read 131209

Klasörleri veya dosyaları salt okunur olarak açma ve kopyalama hakkını belirtir. Bu hak, doğru, ReadExtendedAttributes doğru ReadAttributes ve ReadPermissions doğruyu içerirReadData.

ReadAndExecute 131241

Klasörleri veya dosyaları salt okunur olarak açma ve kopyalama ve uygulama dosyalarını çalıştırma hakkını belirtir. Bu hak, hakkı ve ExecuteFile hakkı içerirRead.

ReadAttributes 128

Bir klasör veya dosyadan dosya sistemi özniteliklerini açma ve kopyalama hakkını belirtir. Örneğin, bu değer dosya oluşturma veya değiştirme tarihini görüntüleme hakkını belirtir. Bu, verileri okuma hakkını, genişletilmiş dosya sistemi özniteliklerini veya erişim ve denetim kurallarını içermez.

ReadData 1

Bir dosya veya klasörü açma ve kopyalama hakkını belirtir. Bu, dosya sistemi özniteliklerini, genişletilmiş dosya sistemi özniteliklerini veya erişim ve denetim kurallarını okuma hakkını içermez.

ReadExtendedAttributes 8

Bir klasör veya dosyadan genişletilmiş dosya sistemi özniteliklerini açma ve kopyalama hakkını belirtir. Örneğin, bu değer yazar ve içerik bilgilerini görüntüleme hakkını belirtir. Bu, verileri, dosya sistemi özniteliklerini veya erişim ve denetim kurallarını okuma hakkını içermez.

ReadPermissions 131072

Klasör veya dosyadan erişim ve denetim kurallarını açma ve kopyalama hakkını belirtir. Bu, verileri, dosya sistemi özniteliklerini ve genişletilmiş dosya sistemi özniteliklerini okuma hakkını içermez.

Synchronize 1048576

Uygulamanın bir G/Ç işleminin tamamlanmasıyla bir dosya tanıtıcısının eşitlenmesini bekleyip bekleyemeyeceğini belirtir. Erişime izin verildiğinde bu değer otomatik olarak ayarlanır ve erişim reddedilirken otomatik olarak dışlanır.

TakeOwnership 524288

Klasör veya dosyanın sahibini değiştirme hakkını belirtir. Bir kaynağın sahiplerinin bu kaynağa tam erişimi olduğunu unutmayın.

Traverse 32

Bir klasörün içeriğini listeleme ve bu klasörün içindeki uygulamaları çalıştırma hakkını belirtir.

Write 278

Klasör ve dosya oluşturma ve dosyalardan veri ekleme veya kaldırma hakkını belirtir. Bu hak, doğru, AppendData doğru WriteExtendedAttributes ve WriteAttributes doğruyu içerirWriteData.

WriteAttributes 256

Dosya sistemi özniteliklerini açma ve bir klasöre veya dosyaya yazma hakkını belirtir. Buna veri yazma, genişletilmiş öznitelikler veya erişim ve denetim kuralları dahil değildir.

WriteData 2

Dosya veya klasör açma ve klasöre yazma hakkını belirtir. Bu, dosya sistemi özniteliklerini, genişletilmiş dosya sistemi özniteliklerini veya erişim ve denetim kurallarını açma ve yazma hakkını içermez.

WriteExtendedAttributes 16

Genişletilmiş dosya sistemi özniteliklerini açma ve klasöre veya dosyaya yazma hakkını belirtir. Bu, veri, öznitelik veya erişim ve denetim kuralları yazma özelliğini içermez.

Örnekler

Aşağıdaki örnek, bir erişim kuralı belirtmek ve ardından bir dosyadan erişim kuralını kaldırmak için numaralandırmayı kullanır FileSystemRights . Bu örneği çalıştırmak için geçerli bir kullanıcı veya grup hesabı sağlamanız gerekir.

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

Açıklamalar

Numaralandırma, FileSystemRights belirli bir kullanıcı hesabı için izin verilen dosya sistemi eylemlerini ve belirli bir kullanıcı hesabı için hangi dosya sistemi eylemlerinin denetlendiği belirtir.

FileSystemRights sınıfla bir erişim kuralı oluştururken veya sınıfıyla FileSystemAccessRule bir denetim kuralı oluştururken numaralandırmayı FileSystemAuditRule kullanın.

Bu numaralandırma, çeşitli ayrıntılı sistem hakları değerleri ve bu tanecik değerlerin birleşimi olan birkaç değer içerir. Her bileşen değerini ayrı ayrı belirtmek yerine , Readve Writegibi FullControlbirleşim değerlerini kullanmak daha kolaydır.

CreateDirectories ve CreateFiles hakları için Synchronize hak gerekir. Bir dosya veya dizin oluştururken değeri açıkça ayarlamazsanız Synchronize , sizin için otomatik olarak ayarlanır.

Şunlara uygulanır