.NET プラットフォームの DirectorySecurity 名前空間 (GetAccessRules() など) のメソッドは、私の目的には遅すぎます。代わりに、NTFS $Secure メタファイル (または、代わりに $SDS ストリーム) を直接クエリして、各ファイル システム オブジェクトのローカル アカウントとそれに関連付けられたアクセス許可のリストを取得したいと考えています。
私の計画は、最初に $MFT メタファイルを読み取り (方法は既に理解しています)、次に、その中の各エントリについて、メタファイル (またはストリーム) 内の適切なセキュリティ記述子を検索することです。
理想的なコード ブロックは次のようになります。
//I've already successfully written code for MFTReader:
var mftReader = new MFTReader(driveToAnalyze, RetrieveMode.All);
IEnumerable<INode> nodes = mftReader.GetNodes(driveToAnalyze.Name);
foreach (NodeWrapper node in nodes)
{
//Now I wish to return security information for each file system object
//WITHOUT needing to traverse the directory tree.
//This is where I need help:
var securityInfo = GetSecurityInfoFromMetafile(node.FullName, node.SecurityID);
yield return Tuple.Create(node.FullName, securityInfo.PrincipalName, DecodeAccessMask(securityInfo.AccessMask));
}
そして、出力を次のようにしたいと思います。
c:\Folder1\File1.txt jane_smith Read, Write, Execute
c:\Folder1\File1.txt bill_jones Read, Execute
c:\Folder1\File2.txt john_brown Full Control
etc.
Windows 10 で .NET バージョン 4.7.1 を実行しています。