Click to See Complete Forum and Search --> : PROBLEM WITH WindowsPrincipal


Amit Jathan
May 15th, 2003, 08:22 AM
I created a New Group Called AppOperators under
Computer Management => Local Users and Groups => Groups

I then added my account into the AppOperator Group, after adding. I refreshed the window using Action => Refresh.

When i run the below code, i am getting the value as False for "Is in AppOperators group". And when i restarted the PC it worked fine (i.e. it returned the value as True)

I have performed this steps several times, but to get the Correct value I have to re-boot the machine.

I have tested the below code on WinXP Professional and Windows 2000 Advance Server with latest SP installed.

I am using VS.NET Version 2002.
Framework Version: 1.0.3705 with SP2 installed.

Am missing something or am i performing any steps incorrectly?
Any information on this would be very helpful.

----------------------------------------------------------
Code:
----------------------------------------------------------
AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal)

Dim user As WindowsPrincipal = CType(System.Threading.Thread.CurrentPrincipal, WindowsPrincipal)

Dim sbDetail As New StringBuilder()

With sbDetail
.AppendFormat("User name: {0}", user.Identity.Name & ControlChars.CrLf)
.AppendFormat("Authentication type: {0}", user.Identity.AuthenticationType & ControlChars.CrLf)
.AppendFormat("Is in AppOperators group: {0}", user.IsInRole("MUJTABA03\AppOperators") & ControlChars.CrLf)
End With

Call MessageBox.Show(sbDetail.ToString, "", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification)

phone_guy
February 28th, 2005, 09:07 AM
Although this is an old post, not much else posted under WindowsPrincipal. For reference, the documentation under the System.Security.Principal.WindowsPrincipal.IsInRole() method states:



Note When testing for newly created role information, such as a new user or a new group, it is important to log out and log in to force the propagation of role information within the domain. Not doing so can cause the IsInRole test to return false.