get currently logged on user

Remember getting the currently logged on widows user in VB6? well in .NET its a lot easier - No more API calls. Just use thesecurity.Principal Namespace and the code :

System.Security.Principal.WindowsIdentity.GetCurrent();

This returns a WindowsIdentity type object. From this object you can get a range of properties that could be useful. IsAuthenticated is another useful property that returns whether the current user has been authenticated by windows.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish