Posts

Showing posts with the label C# Windows Get Currently logged in user

C# Get Currently logged in windows user

using  Microsoft.VisualStudio.TestTools.UnitTesting; using  System.Security.Principal;  /* Namespace needed to get currently logged in user */ namespace  SecurityModules {     [ TestClass ]      public   class   Security     {         [ TestMethod ]          public   void  GetCurrentUser()         {              // Act              var  currentlyLoggedInUser =  WindowsIdentity .GetCurrent().Name ;              // Assert              Assert ...