Pete B [mailto:[EMAIL PROTECTED]] wrote:
> 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'. If this is the case you're always going to want to know about the logical user. Hmmm... ok, this makes things a little more complex. Next questions: In the of ASP.NET, are you going to be using Windows auth with impersonation based on the client? If not, what authentication module are you going to be using? In the ASP.NET case, the logical user is only ever going to be found via HttpContext::User if client impersonation is not used. In the windows service the logical user is going to be coming through Thread::CurrentPrincipal. So you could use that code I pasted to sniff if you're in the context of an ASP.NET request, but if you're components are ever executed in another custom environment like ASP.NET where the logical user is different than the Thread::CurrentPrincipal then you could be in trouble. Another option is, if in ASP.NET you're using something like the FormsAuthenticationModule, you hook into it and change the Thread::CurrentPrincipal. That way your components always look there for the principal information. This requires that the ASP.NET module code be marked with SecurityAttribute and the ControlPrincipal flag. HTH, Drew You can read messages from the DOTNET archive, unsubscribe from DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.