The properties and methods exposed by the My.User object provide access to the information about the current user. The meaning of "current user" differs slightly between Windows and Web applications. In a Windows application, the current user is the user who runs the application. In a Web application, the current user is the user who accesses the application.
The My.User property also provides access to the IPrincipal for the current user. A principal object represents the user's security context, including that user's identity and any roles to which the user belongs.
For Windows applications, this property provides the same functionality as the CurrentPrincipal property. For Web applications, this property provides the same functionality as the User property of the object returned by the Current property.
Note |
|---|
| For Windows applications, only projects built on the Windows Application template initialize the My.User object by default. In all other Windows project types, you must initialize the My.User object by calling the My.User.InitializeWithWindowsUser Method explicitly or by assigning a value to CurrentPrincipal. |
Note |
|---|
| The My.User object cannot report information about the current Windows user when run under Windows 95 and Windows 98 because those operating systems do not support the concept of a logged-on user. You must implement custom authentication to use the My.User object on those operating systems. For more information, see Walkthrough: Implementing Custom Authentication and Authorization. |