Demonstrates determining group identity : Identity : Development Class C# Source Code


Custom Search

C# Source Code » Development Class » Identity »

 

Demonstrates determining group identity









    

/*
Mastering Visual C# .NET
by Jason Price, Mike Gunderloy

Publisher: Sybex;
ISBN: 0782129110
*/


/*
  Example19_7.cs demonstrates determining group identity
*/

using System;
using System.Security.Principal;


public class Example19_6a 
{

    public static void Main() 
    {

        // get the current identity
        WindowsIdentity wi = WindowsIdentity.GetCurrent();
        // get the associated principal
        WindowsPrincipal prin = new WindowsPrincipal(wi);

        if (prin.IsInRole(WindowsBuiltInRole.PowerUser)) 
        {
            Console.WriteLine("You are a member of the Power User group");
        }
        else
        {
            Console.WriteLine("You are not a member of the Power User group");
        }

    }

}



           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Development Class
» Identity