Get UserID and Workstation Name with .NET

In a Winforms application under .NET, need to get the current UserID and Workstation Name.
Must do this without 3rd party tools.  Need to do this in C#
brotherbill999Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DhaestCommented:
Retrieve current Windows user information using VB.NET
http://articles.techrepublic.com.com/5100-10878_11-6115410.html
0
DhaestCommented:
Several solutions
1.  Through an API
Declare Function GetUserName Lib "advapi32.dll" Alias _
       "GetUserNameA" (ByVal lpBuffer As String, _
       ByRef nSize As Integer) As Integer

   Public Function GetUserName() As String
       Dim iReturn As Integer
       Dim userName As String
       userName = New String(CChar(" "), 50)
       iReturn = GetUserName(userName, 50)
       GetUserName = userName.Substring(0, userName.IndexOf(Chr(0)))
   End Function

2. Environment.Username

3.Imports System.Security
Imports System.Security.Principal.WindowsIdentity
After Importing the above
MsgBox(GetCurrent.Name)


0
DhaestCommented:
Workstation:
System.Environment.MachineName
Username
System.Environment.UserName
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
brotherbill999Author Commented:
Wonderful!  Simple and direct.  And it gives me exactly the information I needed! Thank you!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.