User.Name Property 
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the name of the current user.
public:
 property System::String ^ Name { System::String ^ get(); };public string Name { get; }member this.Name : stringPublic ReadOnly Property Name As StringProperty Value
String. The name of the current user.
Examples
This example checks if the application is using Windows or custom authentication, and uses that information to parse the My.User.Name property.
Function GetUserName() As String
    If TypeOf My.User.CurrentPrincipal Is 
      Security.Principal.WindowsPrincipal Then
        ' The application is using Windows authentication.
        ' The name format is DOMAIN\USERNAME.
        Dim parts() As String = Split(My.User.Name, "\")
        Dim username As String = parts(1)
        Return username
    Else
        ' The application is using custom authentication.
        Return My.User.Name
    End If
End Function
Remarks
You can use the My.User object to get information about the current user.
The principal that authenticates the user also controls the format of the user name. By default, an application uses Windows authentication, and the user name has the format DOMAIN\USERNAME. A custom implementation of the principal does not necessarily use the same format.
Note
The exact behavior of the My.User object depends on the type of the application and on the operating system on which the application runs. For more information, see the User class overview.
Availability by Project Type
| Project type | Available | 
|---|---|
| Windows Application | Yes | 
| Class Library | Yes | 
| Console Application | Yes | 
| Windows Control Library | Yes | 
| Web Control Library | Yes | 
| Windows Service | Yes | 
| Web Site | Yes |