如何检查 IIS_IUSR 组是否对某个文件夹具有特殊权限?[说 c:\windows\temp ]
我正在尝试检查它是否具有允许权限。如果它具有允许权限,我认为它具有特殊权限。这个假设正确吗?
internal static Boolean HasAccess(string strPath, string account)
{
var security = Directory.GetAccessControl(strPath);
var rules = security.GetAccessRules(true, true, typeof(NTAccount));
foreach (FileSystemAccessRule rule in rules)
{
if (rule.IdentityReference.Value == account)
{
if (rule.AccessControlType == AccessControlType.Allow)
{
return true;
}
}
}
return false;
}
static void Main(string[] args)
{
if ( HasAccess(@"C:\Windows\Temp", "BUILTIN\\IIS_IUSRS") ) {
Console.WriteLine(" It has permission");
}
}