Tuesday 15 March 2011

ASP.NET get windows username outside of page -


I have an existing ASP.NET reporting application that is using Windows authentication. The report is a very different class of generation code and has a core error logger that I have not written, error logger I believe that Windows was built for applications because it uses WindowsIdentity.GetCurrent (). In the case of ASP.net I believe that it will return the account running the ASPNNet page on the server.

I believe the user Using Identity. The page on the name will be the way to do this correctly but this is not available within the Report Generation Classes on the page, is it a way to get the missing error logger class as an additional parameter

There are hundreds of reports sections, so I have to be afraid that each parameter has to be added.

If you can use cloning in your web.config:

  .... & lt; Authentication mode = "windows" /> & Lt; Identification impersonation = "true" />  

Your report sections will find the right user.

If your reporting classes system Can refer to the web assembly and you are willing to modify the code, you can also:

  httpctx Present. User. Identity .name  

But make sure the caller comes from an ASP.NET request or throw it a null.


No comments:

Post a Comment