I need to get the current principle object that a windows service is executing under. I would like to use the AD account to generate a Csla principal object to work with my business object library. I thought that System.Threading.Thread.CurrentPrincipal would be it, but it seems that it is nothing in the OnStart procedure. The service is running on a Windows Server 2003 R2.
Any thoughts would be greatly appreciated.
To get the current principal of the user account which is running any application, you need to do this:
var prin = new WindowsPrincipal( WindowsIdentity.GetCurrent() );
By default a Thread will have the GenericPrincipal set. You can also modify this (as the first lines of code your execute on startup) using AppDomain.SetPrincipalPolicy or AppDomain.SetThreadPrincipal, depending on what you need to do.
Andy - thanks for the clairification.
Copyright (c) Marimer LLC