Click here to Skip to main content
15,917,321 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

In my Application I am using the Environment.username property for getting the windows login username. If I execute the Application and checked it gives the username correctly as "Admin". After I publish the Application and checked it give the Username as IN$.The System username is IN\Admin. I need to get only the username as "Admin". How to get the username by using this Environment.Username Property.

Thanks
Posted

1 solution

Try this:
System.Environment.GetEnvironmentVariable("Username",EnvironmentVariableTarget.Machine))

or
System.Security.Principal.WindowsIdentity.GetCurrent().Name

or
Guid guid = (Guid)Membership.GetUser().ProviderUserKey;
 
Share this answer
 
Comments
Member 7946563 20-Feb-14 4:37am    
Its not working

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