2012-09-20

Get name of the user account which the website runs under in the server

When you host your website in IIS, it runs under a different user account. It’s not the same account as you host it. To get the user account name which the website runs under, we can use the below code.

Response.Write(WindowsIdentity.GetCurrent().Name);

We have to import the below namespace in order to use the above code

using System.Security.Principal;

No comments: