|
security
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to share a Principal within a ThreadPool ?Hi,
when I set a Principal in the current thread, using : Thread.CurentPrincipal = the Principal object is not set in the other threads of the application threadpool. Is there a special way to do that ? Oriane Hello Oriane,
why would you like to do this?? --------------------------------------- Dominick Baier - DevelopMentor http://www.leastprivilege.com Show quoteHide quote > Hi, > > when I set a Principal in the current thread, using : > > Thread.CurentPrincipal = > > the Principal object is not set in the other threads of the > application threadpool. > > Is there a special way to do that ? > > Oriane > "Dominick Baier [DevelopMentor]" <dbaier@pleasepleasenospamdevelop.com> Good question ! I would like to do this because I want to handle thewrote in message news:304286632501419246158320@news.microsoft.com... > Hello Oriane, > > why would you like to do this?? authorization for "applicative users" in my app, which of course has many threads. So if I set the principal in a thread (say the presentation one), and then use declarative authorization with the PrincipalPermissionAttribute in another thread, it won't work... Hello Oriane,
set Context.User to the specific IPrincipal (e.g. in AuthenticateRequest) - there is a "semi documented" event firing after AuthenticateRequest called "DefaultAuthentication" which copies Context.User to Thread.CurrentPrincipal. After that your PrincipalPermissions should work. --------------------------------------- Dominick Baier - DevelopMentor http://www.leastprivilege.com Show quoteHide quote > "Dominick Baier [DevelopMentor]" > <dbaier@pleasepleasenospamdevelop.com> wrote in message > news:304286632501419246158320@news.microsoft.com... > >> Hello Oriane, >> >> why would you like to do this?? >> > Good question ! I would like to do this because I want to handle the > authorization for "applicative users" in my app, which of course has > many threads. So if I set the principal in a thread (say the > presentation one), and then use declarative authorization with the > PrincipalPermissionAttribute in another thread, it won't work... > > Hi, If You write an ASP.NET application use Context.User instead of > when I set a Principal in the current thread, using : > Thread.CurentPrincipal = > the Principal object is not set in the other threads of the application > threadpool. > Is there a special way to do that ? > Oriane Thread.CurrentPrincipal. Contexct.User sets principal for all threads. You can also use AppDomain.SetThreadPrincipal But this method could be used only once. "Aleksandr Sliborsky" <Aleksandr Slibor***@discussions.microsoft.com> wrote Thanksin message news:6BB2A67C-C412-44D5-9B43-0050D8183166@microsoft.com... [...] > You can also use AppDomain.SetThreadPrincipal > But this method could be used only once. Fine. Hello Aleksandr,
That's not true. Context.User is for the current thread only. And you have to do that for every request, e.g. in Application_AuthenticateRequest. This is the recommended way of doing it. --------------------------------------- Dominick Baier - DevelopMentor http://www.leastprivilege.com Show quoteHide quote >> Hi, >> when I set a Principal in the current thread, using : >> Thread.CurentPrincipal = >> the Principal object is not set in the other threads of the >> application >> threadpool. >> Is there a special way to do that ? >> Oriane > If You write an ASP.NET application use Context.User instead of > Thread.CurrentPrincipal. > Contexct.User sets principal for all threads. > You can also use AppDomain.SetThreadPrincipal > But this method could be used only once.
Encrypt with RijndaelManaged and decrypt with OpenSSL
IsAuthenticated property on IIdentity interface UIPermission Clipboard running dll from a network share Event Log Write access under ASP.NET Creating User Accounts with or without Active Directory Windows Authentication Newbie Question Upgrading Encryption to .Net not Working!!!!!!! Access denied with interop Windows security context |
|||||||||||||||||||||||