Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Exemple de politique de Sécurité avec ‘PolicyLevel’ et ‘PermissionSet’

Charger,une,Assemblée,avec,un,nom
{filelink=17576}

using System;
using System.Threading;
using System.Security;
using System.Security.Policy;
using System.Security.Permissions;
 
  class ExemplePolicyLevel
  {
    static void Main(string[] args)
    {
      AppDomain domaine = System.AppDomain.CreateDomain("MonDomaine");
      PolicyLevel polLevel = PolicyLevel.CreateAppDomainLevel();
      PermissionSet ModifPermission = new PermissionSet(PermissionState.None);
      ModifPermission.AddPermission(new SecurityPermission(SecurityPermissionFlag.Execution));
      polLevel.RootCodeGroup.PolicyStatement = new PolicyStatement(ModifPermission);
      domaine.SetAppDomainPolicy(polLevel);
      domaine.ExecuteAssembly(@"AssembliesMonApplication.exe");
      AppDomain.Unload(domaine);
    }
  }

No comments yet.

Leave a Comment