Use Windows Role-Based Security

Problem

You want to determine application privileges based on group membership.

Solution

Create a WindowsPrincipal object from the current WindowsIdentity, and call the IsInRole method.

Discussion

The Windows operating system allows you to place users in groups and give these groups different permissions for accessing resources such as files and the registry. In addition, you can create application-specific groups (such as Sales-Managers, Contractors, and so on), examine these in your code, and then configure the behavior of your application accordingly. To configure groups and group members, select Computer Management from the Control Panel. Figure 18-1 shows the Computer Management console with some common groups. ...

Get Microsoft® Visual Basic® .NET Programmer's Cookbook 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.