Click to See Complete Forum and Search --> : Is there an IsInGroup Function


David Stephen
December 17th, 2002, 09:55 PM
I would like to check if a user on an ASP.net web form is in a particular group.

I have Forms authentication turned on and need to check programitacilly if a user is in a group or not to allow access to various fnctions.

There is a User.IsInRole function but I always get false for just the Group Name or Domain/Group Name.

Is a Role different to a Group?

Any samples around like this?

Also, is there a way to identify all the groups in a domain via WMI or something?

Thank you

David

David Stephen
December 18th, 2002, 03:25 PM
User.IsInRole exists in web forms and can be used as

User.IsInRole("Domain\Group")

However, if the Group is predefined by Windows then you need to use
BUILTIN\Group

I have seen code that actually checks security like

Dim wp As New System.Security.Principal.WindowsPrincipal(CType(User.Identity, System.Security.Principal.WindowsIdentity))
wp.IsInRole("Domain\Group")

But I do not know why the difference.

I still can not find out how to get the list of groups on a network.