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 the security.Principal Namespace and the code : Syst

ITPro Today

March 28, 2004

1 Min Read
ITPro Today logo in a gray background | ITPro Today

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.

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like