I understand that this post is quite old, but I thought that I could update it using the processes that I use. (ASP.Net 4.0, VB)
If you use integrated window protection in a domain.
Page.User.IsInRole("domain\GroupName") checks if the authenticated user is a member of the specified group.
If you want to check other membership in the user group, besides the authenticated user.
Two steps for checking multiple groups with the same user:
Dim MyPrincipal As New System.Security.Principal.WindowsPrincipal _ (New System.Security.Principal.WindowsIdentity("UserID")) Dim blnValid1 As Boolean = MyPrincipal.IsInRole("domain\GroupName")
One step to test one group:
Dim blnValid2 As Boolean = New System.Security.Principal.WindowsPrincipal _ (New System.Security.Principal.WindowsIdentity("userID")).IsInRole("domain\GroupName")
NOTE :: The IsInRole method works with nested groups. If you have a top-level group with a subgroup that is a member and the user is a member of a subgroup.
Jim m
source share