Csharp/C Sharp/Security/SecurityManager

Материал из .Net Framework эксперт
Перейти к: навигация, поиск

CheckExecutionRights, SavePolicy

 
using System.Security;
class MainClass {
    public static void Main() {
        SecurityManager.CheckExecutionRights = true;
        SecurityManager.SavePolicy();
        SecurityManager.CheckExecutionRights = false;
        SecurityManager.SavePolicy();
    }
}


PolicyHierarchy

 
using System;
using System.Security.Policy;
using System.Security;
using System.Collections;
class Class1 {
    static void Main() {
        IEnumerator PolicyEnum = SecurityManager.PolicyHierarchy();
        while (PolicyEnum.MoveNext()) {
            PolicyLevel levelPolicy = (PolicyLevel)PolicyEnum.Current;
            Console.WriteLine(levelPolicy.Label);
            IEnumerator PermissionEnum = levelPolicy.NamedPermissionSets.GetEnumerator();
            while (PermissionEnum.MoveNext()) {
                NamedPermissionSet permissionSet = (NamedPermissionSet)PermissionEnum.Current;
                Console.WriteLine("\tPermission Set: \n\t\t Name: {0} \n\t\t Description {1}", permissionSet.Name, permissionSet.Description);
            }
        }
    }
}