12.9. Determine Whether the Current User Is a Member of a Specific Windows Group
Problem
You need to determine if the current user of your application is a member of a specific Windows user group.
Solution
Obtain a System.Security.Principal.WindowsIdentity object representing the current Windows user by calling the Shared method WindowsIdentity.GetCurrent. Create a System.Security.Principal.WindowsPrincipal class using the WindowsIdentity class, and then call the method IsInRole of the WindowsPrincipal object.
How It Works
The role-based security (RBS) mechanism of the .NET Framework abstracts the user-based security features of the underlying operating system through the following two key interfaces:
The System.Security.Principal.IIdentity ...
Get Visual Basic 2008 Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.