[Mono-bugs] [Bug 59683][Min] Changed - Setting Context.User does not update Thread.CurrentPrincipal

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Mon, 7 Jun 2004 15:13:58 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by sebastien@ximian.com.

http://bugzilla.ximian.com/show_bug.cgi?id=59683

--- shadow/59683	2004-06-07 12:00:53.000000000 -0400
+++ shadow/59683.tmp.20477	2004-06-07 15:13:58.000000000 -0400
@@ -56,6 +56,39 @@
 However I can't get your open sample case (did you select the file
 type when attaching) and se how you get PrincipalPermission.Demand to
 throws an exception on Debian (as it shouldn't). 
 
 Could you reattach your sample (selecting the appropriate MIME type)
 and giving it a name with an extension.
+
+------- Additional Comments From sebastien@ximian.com  2004-06-07 15:13 -------
+Fixed in CVS (at least the part I could reproduce). I still don't see
+how you can get an exception on Debian. 
+
+Anyway here's the code I used to test it (on Fedora Core 1). Note that
+the code won't run under MS runtime because you can't create a
+HttpContext like this.
+
+
+using System;
+using System.Security.Principal;
+using System.Threading;
+using System.Web;
+
+class T {
+	static void Main () 
+	{
+		string[] roles = new string [1] { "hackers" };
+		IPrincipal p = (IPrincipal) new GenericPrincipal (new
+GenericIdentity ("me"), roles);
+
+		HttpContext c = new HttpContext (null);
+		c.User = p;
+
+		Console.WriteLine ("Hacker ? {0}", Thread.CurrentPrincipal.IsInRole
+("hackers"));
+	}
+}
+
+
+Please close the bug if this fix the problem (or re-open with more
+details). Thanks.