User.InitializeWithWindowsUser Method

Definition

Sets the thread's current principal to the Windows user that started the application.

public:
 void InitializeWithWindowsUser();
public void InitializeWithWindowsUser ();
member this.InitializeWithWindowsUser : unit -> unit
Public Sub InitializeWithWindowsUser ()

Remarks

You can use the My.User.InitializeWithWindowsUser method to set the thread's current principal to the Windows user that started the application. The Visual Basic Application Model in a Windows application calls this method at startup by default. In other project types, you must set the thread's current principal by calling this method explicitly or by assigning a value to Thread.CurrentPrincipal.

In Windows projects, the My.User object is based on the thread's current principal; therefore, this method can change the information My.User returns. In an ASP.NET application, the My.User object is based on the current HTTP request's user identity, and is unaffected by this method.

Note

The exact behavior of the My.User object depends on the type of application and on the operating system on which the application runs. For more information, see the User class overview.

This is an advanced member; it does not show in IntelliSense unless you click the All tab.

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

Applies to

See also