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
  • 160,644
  • 26
  • 247
  • 397
Ramandeep Singh
  • 83
  • 1
  • 1
  • 13

2 Answers2

2
var username = Environment.UserName
Pawel Maga
  • 5,428
  • 3
  • 38
  • 62
1

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

DasDas
  • 571
  • 3
  • 9
  • 32