Get Logged In User Name


//**************************************
    // Name: Get Logged In User Name
    // Description:Gets the name of the user logged into a Windows machine on a network.
    // By: Darrin Mason
    //
    //
    // Inputs:None
    //
    // Returns:None
    //
    //Assumes:None
    //
    //Side Effects:None
    //This code is copyrighted and has limited warranties.
    //Please see http://www.1PHPStreet.com/xq/ASP/txtCodeId.1600/lngWId.10/qx/vb/scripts/ShowCode.htm
    //for details.
    //**************************************
    
    ' If you want just the user name, use th
    //     is code:
    Public Function GetUserName() As String
    GetUserName = (SystemInformation.UserName.ToString)
    //     ' This will return only the user name
    End Function
    ' If you want the domain name included, 
    //     use the code:
    Imports System
    Imports System.Security
    Public Module SysInfo
    Public Function GetUserName() As String
    Principal.WindowsIdentity.GetCurrent.Name
    //     ' This will return 'domain\username'
    End Function
    End Module
    ' You can also call the code direct, suc
    //     h as Text1.Text = (SystemInformation.Use
    //     rName.ToString)