.net - Declarative security demands - Is SecurityAction.Demand cached? -


I have a problem during the impersonation of a user. I have one such method:

 Static Zero Localetting Group only () {console .site lin ("Inside Localtast Group Only (" Demand, Name = @ "DJPeter-PC \ Test", Roll = "Local Tasting Group")) ) - {0} ", Windows Identity.Gate Current (.));); }  

The calling code is:

  WindowsImersonationContext reference = WindowsIdentity.Impersonate (token); Console WrightLine ("Calling LocalTest Group Only () {0}", WindowsIdentity.GetCurrent (.name)); LocalTestGroupOnly (); Context.Undo (); Try that the {// reverted user has been displayed correctly Console.WriteLine ("Calling LocalTestGroupOnly () only {0}", WindowsIdentity.GetCurrent ().); // This method should fail, but if Local TestGroup only succeeds (); } Grip (before security Exception) {Console.WriteLine ("That function is not allowed in your account."); }  

The default user is not a member of LocalTestGroup, the user indicated by the token IS member of the localtast group.

Issue:

The first call is successful only for the localtast group because the user has been notified by the token IS member of the localt group. The second call (as the default user) LocalTestGroupOnly () should fail because the default user is not 'test' and it is not related to LocalTestGroup. The problem is that this method also succeeds.

If I run the program individually - our right to behave without any impersonation: It succeeds when cloned as 'Test' and calling as the default user Fails in

What is the problem here?

Can you check the thread. At present Principal instead of WindowsIdentity.GetCurrent () ? PrincipalPermission.Demand () Uses first. To change Thread.CurrentPrincipal (or HttpContext.User ) It seems that you have to set them explicitly after impersonation or some After the undo Check the same question.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -