views:

259

answers:

2

I have an ASP.NET 3.5 application (on IIS 6.0) which uses ASP.NET forms authentication. In my IIS logs, I have extended logging turned on including the cs-username field. Even after a user has logged in to my site, the cs-username still displays '-'.

Is there a way to get the authenticated ASP.NET user's name to appear in the username field in the logs?

+1  A: 

Not easily.

cs-username by default is the HTTP authentication username, not forms authentication. You might be able to write an ISAPI DLL to intercept the call, parse the ASP.NET auth token cookie, decrypting it if you have to and retrieve the username from the membership providerthen intercept SF_NOTIFY_LOG and respond to the ON_LOG event to set the right name, but it's non-trivial.

blowdart
A: 

Alernatively, use the ASP.NET memebership provider to write some customised codes to record them in the database!