Fog Creek Software
Discussion Board

Welcome! and rules

Joel on Software

Security in .NET


I'm wondering how to check in which group the current user is in when the group is a custom made group in windows XP/2000.
For example: if I create a new group in XP and add a new user to that group, I would like my program to check if the current user is a member of that (custom) group before continuing executing.

I'm aware of functions like AllocateAndInitializeSid(...) and CheckTokenMembership(...) -also usable in unmanaged code- which I can't get to check on the custom made group.

Is there a way in .NET to do that?
And if not, does anyone know how to use AllocateAndInitializeSid(...) and CheckTokenMembership(...) in this case?

Many thanks in advance for any suggestions,
Grtz. jurgen

Wednesday, May 19, 2004


Yes, this is quite possible and fairly easy. Unfortunately, I don't have my code in front of me or I would give you a code snippet.

Do a google on "dotnet and NT groups" and I think you'll find plenty of examples.

Mark Hoffman
Wednesday, May 19, 2004

You want System.Security.Principal.IPrincipal.IsInRole

Mike Gunderloy
Thursday, May 20, 2004


Sunday, May 23, 2004

*  Recent Topics

*  Fog Creek Home