i use the below code to get logged in user name.
private string GetLoggedInUser()
{
string userName = "";
if (System.Security.Principal.WindowsIdentity.GetCurrent() != null)
{
userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
}
return userName;
}
just do not understand why it is not giving a logged in user name rather it is return data in this format NT AUTHORITY\SYSTEM
but i want to get user name.
i try to run my service as Local Service and local system account
but in every case i am getting this string NT AUTHORITY\SYSTEM
instead of logged in user name.
so please guide me what to change in code. thanks