Ejemplo n.º 1
0
        /// <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);
            }
        }
Ejemplo n.º 2
0
 /// <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;
     }
 }