lima-city: Webhosting, Domains und Cloud
1 Pluspunkt 0 Minuspunkte

Ich lese die NTFS Berechtigungen von einem Windows Fileshare.

DirectoryInfo directoryInfo = new DirectoryInfo(folderPath);
DirectorySecurity directorySecurity = directoryInfo.GetAccessControl();
AuthorizationRuleCollection acl = directorySecurity.GetAccessRules(true, true, typeof(NTAccount));

foreach (FileSystemAccessRule rule in acl)
{
	string rights = rule.FileSystemRights.ToString();
}

Die Ausgabe ist aber immer nur z.B

Read&Execute
Modify
FullControl

Wie kann ich die erweiterten NTFS Berechtigungen wie z.B

TraverseDirectory
ReadAttributes
ReadExtendedAttributes

anzeigen?

von  

1 Antwort

0 Pluspunkte 0 Minuspunkte

Du kannst eine Funktion dazu schreiben.

private static List<string> GetDetailedRights(FileSystemRights rights)
{

    List<string> detailedRights = new List<string>();

    foreach (FileSystemRights value in Enum.GetValues(typeof(FileSystemRights)))
    {

        if (value == 0) continue; // Ignore 'None'

        if (rights.HasFlag(value))
        {
            detailedRights.Add(value.ToString());
        }

    }

    return detailedRights;

}

Die Liste an Berechtigungen kannst du dann zu einem String zusammenfügen.

List<string> detailedRightsList = GetDetailedRights(rule.FileSystemRights);
string detailedRights = string.Join(", ", detailedRightsList);
von (1.1k Punkte)