Esempio n. 1
0
 public PermissionsChecker(WindowsIdentity current, AuthorizationRuleCollection rules,
                           RequiredCheck requiredCheck)
 {
     _current = current;
     _groups  = _current.Groups.ToHashSet();
     _rules   =
         rules.Cast <FileSystemAccessRule>()
         .ToHashSet();
     _requiredCheck = requiredCheck;
 }
 /// <summary>
 ///     Check permissions
 /// </summary>
 /// <param name="path">Path</param>
 /// <param name="checkRead">Check read</param>
 /// <param name="checkWrite">Check write</param>
 /// <param name="checkModify">Check modify</param>
 /// <param name="checkDelete">Check delete</param>
 /// <returns>Resulr</returns>
 private static bool CheckPermissions(RequiredCheck requiredCheck, string path)
 {
     WindowsIdentity current = WindowsIdentity.GetCurrent();
     try
     {
         var rules = Directory.GetAccessControl(path).GetAccessRules(true, true, typeof(SecurityIdentifier));
         var permissionsChecker = new PermissionsChecker(current, rules, requiredCheck);
         return permissionsChecker.IsValid();
     }
     catch
     {
         return true;
     }
 }