我编写了一个简单的代码来检索文件夹的安全信息,该信息包含用户和组以及他们对文件夹的权限
public void GetSecurityRules(DirectoryInfo directoryInfo)
{
DirectorySecurity DSecurity = directoryInfo.GetAccessControl();
AuthorizationRuleCollection Rules = DSecurity.GetAccessRules(true, true, typeof(NTAccount));
foreach (FileSystemAccessRule fileSystemAccessRule in Rules)
{
Console.WriteLine("User/Group name {0}",fileSystemAccessRule.IdentityReference.Value);
Console.WriteLine("Permissions: {0}", fileSystemAccessRule.FileSystemRights.ToString());
}
}
在这一行中fileSystemAccessRule.IdentityReference.Value
,我同时获得了用户和组,但我如何知道该值是代表用户还是组?