0

i want the user name of the that id from which user is logged in system.

System.Security.Principal.WindowsPrincipal p = System.Threading.Thread.CurrentPrincipal as System.Security.Principal.WindowsPrincipal;
string strName = p.Identity.Name;

I have written above code but not getting the user name but it is giving the alias name

John Saunders
  • 159,224
  • 26
  • 237
  • 393
Ramandeep Singh
  • 83
  • 1
  • 1
  • 13

2 Answers2

2
var username = Environment.UserName
Pawel Maga
  • 4,897
  • 3
  • 37
  • 60
1

string strName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;

DasDas
  • 551
  • 2
  • 9
  • 32