I
innesm
Hi,
Although I havent been able to find any documentation to confirm it, it
looks like any change to a windows local group's membership is only
reflected in the group editing UI (and the command-line tool 'net
localgroup'), and requires a full reboot of windows to take effect for
any other applications.
Can anyone confirm this, or explain why I am getting behaviour that
gives this impression?
I've written a small C# application to demonstrate this:
IsInRole.cs:
============
using System;
using System.Security.Principal;
class App
{
static void Main(string[] args)
{
WindowsPrincipal wp =
new WindowsPrincipal(WindowsIdentity.GetCurrent());
string group = args[0];
bool isInRole = wp.IsInRole(group);
string name = wp.Identity.Name;
Console.WriteLine("User {0} is in role {1}: {2}",
name, group, isInRole);
}
}
Here's the output, comparing with 'net localgroup':
==================
C:\>net localgroup testgroup
....
Members
-----------
MYDOMAIN\me
....
C:\>isinrole MYCOMPUTER\testgroup
User MYDOMAIN\me is in role MYCOMPUTER\testgroup: False
As you can see, 'net localgroup' can see that MYDOMAIN\me is a member
of the local group, but WindowsPrincipal.IsInRole cannot.
If I reboot windows, WindowsPrincipal.IsInRole gives the correct
answer, until I remove MYDOMAIN\me from the group, when it incorrectly
indicates that the user is still in the local group.
Although I havent been able to find any documentation to confirm it, it
looks like any change to a windows local group's membership is only
reflected in the group editing UI (and the command-line tool 'net
localgroup'), and requires a full reboot of windows to take effect for
any other applications.
Can anyone confirm this, or explain why I am getting behaviour that
gives this impression?
I've written a small C# application to demonstrate this:
IsInRole.cs:
============
using System;
using System.Security.Principal;
class App
{
static void Main(string[] args)
{
WindowsPrincipal wp =
new WindowsPrincipal(WindowsIdentity.GetCurrent());
string group = args[0];
bool isInRole = wp.IsInRole(group);
string name = wp.Identity.Name;
Console.WriteLine("User {0} is in role {1}: {2}",
name, group, isInRole);
}
}
Here's the output, comparing with 'net localgroup':
==================
C:\>net localgroup testgroup
....
Members
-----------
MYDOMAIN\me
....
C:\>isinrole MYCOMPUTER\testgroup
User MYDOMAIN\me is in role MYCOMPUTER\testgroup: False
As you can see, 'net localgroup' can see that MYDOMAIN\me is a member
of the local group, but WindowsPrincipal.IsInRole cannot.
If I reboot windows, WindowsPrincipal.IsInRole gives the correct
answer, until I remove MYDOMAIN\me from the group, when it incorrectly
indicates that the user is still in the local group.