Retrieving the username for the current user

This is how to retrieve the username for the currently logged in user:

WindowsIdentity myIdentity = WindowsIdentity.GetCurrent();
string username = myIdentity.Name;

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.