System.Diagnostics: how to register using an id

I did a System.Diagnostics based tracing.

I am also using System.Diagnostics.TextWriterTraceListener and hooked up all tracing back to MOSS 2007 web application.

For some reason, the trace is trying to (a) create a log file and / or (b) write to a log file with the user who is currently browsing the SharePoint site , is there any way to configure the logging to use a specific user account?

+1


source to share


2 answers


Obviously MOSS is configured to use Windows authentication (kerberos) and impersonation. If you don't need to impersonate the current user logged into moss, turn off impersonation (its in web.config). You will find that the log files will be generated and written by the user running your application pool for installing moss.

If you need to use impersonation, then another solution is to grant all the rights to create and write files in the log directory (and ONLY in the log directory). However, this is not exactly the best idea. You can deny read permissions for everyone but those that need to read the logs, but you still have to worry about trying to do a DoS by filling the disk.

The third option is to switch identifiers before registering. Perhaps something like this:



var wic = WindowsIdentity.Impersonate(IntPtr.Zero); // "revert to self"
/* LOG GOES HERE K */
wic.Undo(); // return to impersonation

      

BIG CAVEAT: I'm just studying this stuff myself, so the above code may not work at all. If so, its sweet because you won't have to p / invoke to log your log entry, which also means you won't have to create that user and store your password in cleartext in your application.

I wonder where ol Sketer is on this one? Windows security requires some heavy lifting; I'm just starting at the bar right now ...

+1


source


Please don't tell me this is necessary - http://www.15seconds.com/Issue/040511.htm?voteresult=5



0


source







All Articles