You should try setting the authentication mode to Windows in your configuration & also disable anonymous users in authorization tag. (from a previous answer):
To get the currently logged in user to a Windows account you have to use Windows authentication
instead of Forms authentication
:
In debug in local PC, get Windows UserName, but in server get "NT AUTHORITY\NETWORK SERVICE";
It shows the application current user. When you host your application on the Visual Studio web server it uses your local account. However, when you will log in to the web application with different credentials it will always show your current Windows login.
An application deployed to IIS uses the NT AUTHORITY\SYSTEM account in your case.