My web application is a product which has to deploy to a variety of web servers. Is there a way to determine the account name that the .Net worker process account is using at runtime?
Using .Net 3.5, C#
Thanks in advance
-Pete
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Have you tried
System.Environment.UserName?Edit:
You’re right, the environment username doesn’t seem to work. Here’s something else you could try, which I’ve tested on IIS 7 / Windows Vista:
System.Security.Principal.WindowsIdentity.GetCurrent().NameReturns “NT AUTHORITY\NETWORK SERVICE” for me since my default app pool runs as network service.