I'm just going to validate that a user is within a certain role and perform tasks or filter data based on that role. I'll define a separate 'superuser' and I'd like my window's service to run in the context if this 'superuser'.
>From: "Marsh, Drew" <[EMAIL PROTECTED]> >Reply-To: dotnet discussion <[EMAIL PROTECTED]> >To: [EMAIL PROTECTED] >Subject: Re: [DOTNET] how to pass httpcontext.user to another assembly >Date: Fri, 26 Apr 2002 14:28:31 -0400 > >Pete B [mailto:[EMAIL PROTECTED]] wrote: > > > I have assemblies that are accessed from both ASP.NET apps > > and from windows services built with DOTNET. > > > > What should I do in the second case? > >Ahh... well there's a big difference between the two. The question is, >which >do your components need: the logical principal or the actual principal? >What >are your components going to do with the principal information? > > > In my windows service should I set thread::currentprincipal > > equal to my user, then in my assemblies I can check either > > HttpContext::User or Thread::CurrentPrincipal for a valid user? > >Sure, you could do something something like: > ><codeSnippet language="C#"> >HttpContext currentHttpContext = HttpContext.Current; >IPrincipal currentPrincipal; > >if(currentHttpContext != null) >{ > currentPrincipal = currentHttpContext.User; >} >else >{ > currentPrincipal = Thread.CurrentPrincipal; >} > >... use principal here ... ></codeSnippet> > >You can read messages from the DOTNET archive, unsubscribe from DOTNET, or >subscribe to other DevelopMentor lists at http://discuss.develop.com. _________________________________________________________________ Join the world’s largest e-mail service with MSN Hotmail. http://www.hotmail.com You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.