Digg StumbleUpon LinkedIn YouTube Flickr Facebook Twitter RSS Reset

Exemple ‘PrincipalPerm.Demand’

Exemple,d'utilisation,de,'PermissionSet'
{filelink=17851}

using System;
using System.Security;
using System.Security.Principal;
using System.Security.Permissions;
 
class Class1 {
    static void Main(string[] args) {
        WindowsIdentity wi = WindowsIdentity.GetCurrent();
        PrincipalPermission PrincipalPerm = new PrincipalPermission(wi.Name, "Administrator");
 
        try {
            PrincipalPerm.Demand();
            Console.WriteLine("Code demand for an administrator succeeded.");
        } catch (SecurityException e) {
            Console.WriteLine("Demand for administrator failed!");
            Console.WriteLine(e.Message);
        }
    }
}

No comments yet.

Leave a Comment