Permission settings

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security;
using System.Security.Permissions;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Trust_Test
{
    class Program
    {
        #region  Demand
        //static void Main(string[] args)
        //{
        //    string sFile = @"C:\data.txt";
        //    CodeAccessPermission cap = new FileIOPermission(FileIOPermissionAccess.Read, sFile);
        //    try
        //    {
        //        cap.Demand();
        //    }
        //    catch (SecurityException e)
        //    {
            	
        //    }
        //}
        #endregion

        #region  Deny_RevertDeny

        //static void Main()
        //{
        //    PermissionSet ps = new PermissionSet(PermissionState.None);
        //    ps.AddPermission((new FileIOPermission(FileIOPermissionAccess.AllAccess, @"C:\WINDOWS")));
        //    ps.AddPermission(new RegistryPermission(RegistryPermissionAccess.AllAccess, string.Empty));
        //    ps.Deny();
        //    CodeAccessPermission.RevertDeny();
        //}
        #endregion 
        #region  Assert_RevertAssert

        static void Main()
        {
            CodeAccessPermission cap = new RegistryPermission(RegistryPermissionAccess.NoAccess, string.Empty);
            cap.Assert();
            RegistryPermission.RevertAssert();
        }
        #endregion
    }
}

Reproduced in: https: //www.cnblogs.com/tianjinquan/archive/2010/12/10/1902639.html

Intelligent Recommendation

User permission settings for mysql5.7

All statements about permission modification need to refresh the mysql system permission related table to take effect. Mysql permission table refers to the five tables in the mysql database: user, db,...

Rundeck permission settings

This article environment centos7, Rundeck 3.0.7 target setting permissions so that users (developers) read-only permissions can browse files on the service Directly attach the configuration file cd /e...

HDFS ACL permission settings

HDFS version: 3.1.1 Today I mainly tell you about the HDFS file permissions. When onegeneral userGo to visitHDFS fileWhen it is reportedPermission deniedmistake. So what do you do? Like modifying a li...

Linux - permission settings

A file or directory in Linux has 3 roles: owner Group other people Each of these three roles has different permissions. Linux user account password and group record file location 1 account and general...

More Recommendation

MIUI application permission settings

Whether you think that I write good or bad can tell me in the comments below, your support is the motivation for me to continue to write down, thank you! As miui becomes more and more closed, Xiaomi's...

Permission settings in vue

First, the scene Front and back separation spa page permission settings Second, the technology stack Vue family bucket Third, achieve the effect log in page Fourth, the realization principle The vueRo...

ASP.Net MVC permission settings

Author: Wang Wenqing Development tools and key technologies:VS+ASP.Net MVC +SQL Server Database design: user table SYS_Users User ID UsersID User type ID UsersTypesID account number AccountNumber pass...

Permission settings in Linux

One. The calculation of the permission is to start with the first letter removed, the permission is a combination of three symbols, where - indicates that there is no such permission. The meaning of d...

Android SharedPreferences permission settings

Description: Since I am currently planning to use two apps to do one thing, using SharedPreferences to do data exchange, I suddenly want to verify that the permission settings of the Java layer will b...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top