.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> Windows Application >> Post New QuestionBookmark and Share Subscribe to Forum

how to Get Local users

Posted By: subash     Posted Date: June 09, 2009    Points:2   Category :Windows Application
Hi

In my system i have 3 user accounts that is login accounts.I created via Control Panel->User accounts
My question is how to retrieve this username using c#

Thanks
Subash

Responses
Author: Amit Mehra             
Posted Date: June 11, 2009     Points: 5   

Hi,
If your want to get the logged in user name you can do like this


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


Make sure that you have import namespace

using System.Security.Principal;


if you want to get all the user refer this article

http://www.omegacoder.com/?p=236

Thanks,
Amit
Please "Mark As Answer " if this post help you.
Author: Narayanan             
Posted Date: January 17, 2012     Points: 20   

Hi,
try these
  string userName = Environment.UserName; 
System.Security.Principal.WindowsIdentity.GetCurrent().Name


Regards, Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend