Click here to Skip to main content
15,903,030 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hi everyone, is it possible for a .NET application to get the currently logged on user (username) if this application has been started with runas? I tried System.Security.Principal.WindowsIdentity.GetCurrent().Name but it returned the 'runas' user, not the logged on one. I hope you understand what I meant! Thanks! Larry86
Posted

Yeah I tried it and it also returns the 'runas' user.
 
Share this answer
 
Thank you :
i think you can implement it using (WMI) by passing a (WQL) related to the system information queries.
you can do that using System.Management.ManagementObject
 
Share this answer
 

Have you tried System.Environment.UserName yet?

 

Hogan

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900