IsInRole ?

From: Johan van Zyl (j_at_telstra.com)
Date: 07/18/03


Date: Thu, 17 Jul 2003 16:49:07 -0700


I'm trying to determine whether the current user belongs
to a specific user group. I can only get this to work when
checking against the builtin user groups, it fails
whenever I try to do the check against a user created
group.

I have group called LogAdmins and my user is part of this
group as well as the Administrators group. Here is a code
example, one can see that I've tried various strings for
the group to check against:

public static void getPermission()
                {
                        AppDomain myDomain =
Thread.GetDomain();
                        myDomain.SetPrincipalPolicy
(PrincipalPolicy.WindowsPrincipal);
                        WindowsPrincipal myPrincipal =
(WindowsPrincipal)Thread.CurrentPrincipal;

                        MessageBox.Show
(myPrincipal.IsInRole(@"BUILTIN\Administrators").ToString
());
                        MessageBox.Show
(myPrincipal.IsInRole(@"DEVDOMAIN\LogAdmins").ToString());
                        MessageBox.Show
(myPrincipal.IsInRole(@"BUILTIN\LogAdmins").ToString());
                        MessageBox.Show
(myPrincipal.IsInRole(@"LogAdmins").ToString());
                }

The results are:
True
False
False
False

Is there anyone that might be able to point me in the
right direction please?

JvZ