WindowsPrincipal.IsInRole : Windows Principal « Windows « C# / C Sharp






WindowsPrincipal.IsInRole



using System;
using System.Security.Principal;

class MainClass {
    public static void Main(string[] args) {
        WindowsIdentity identity = WindowsIdentity.GetCurrent();
        WindowsPrincipal principal = new WindowsPrincipal(identity);
        foreach (string role in args) {
            Console.WriteLine("Is {0} a member of {1}? = {2}",
             identity.Name, role, principal.IsInRole(role));
        }

    }
}
           
       








Related examples in the same category

1.Use Properties of WindowsPrincipal
2.WindowsImpersonationContext
3.Get Current Windows Identity
4.WindowsBuiltInRole.Administrator
5.WindowsPrincipal Enables You to Check for Role MembershipWindowsPrincipal Enables You to Check for Role Membership