Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

User Information Sample

This sample provides an overview of the My.User object and the Login Form template. It implements a simple custom authentication.

To get samples and instructions for installing them

  • Do one or more of the following:

    • On the Help menu, click Samples.

      The Readme displays information about samples.

    • Visit the Visual Studio 2008 Samples Web site. The most recent versions of samples are available there.

    • Locate samples on the computer on which Visual Studio is installed. By default, samples and a Readme file are installed in drive:\Program Files\Microsoft Visual Studio 9.0\Samples\lcid. For Express editions of Visual Studio, all samples are located online.

For more information, see Visual Studio Samples.

Security noteSecurity Note:

This sample code is intended to illustrate a concept, and it shows only the code that is relevant to that concept. It may not meet the security requirements for a specific environment, and it should not be used exactly as shown. We recommend that you add security and error-handling code to make your projects more secure and robust. Microsoft provides this sample code "AS IS" with no warranties.

To run this sample

  • Press F5.

This sample demonstrates these tasks:

  • User name   The current Windows user's name is displayed on the main form. This value is retrieved from the My.User Object.

  • Database access   My.User allows developers to plug in their own means of custom authentication and authorization by means of the IPrincipal and IIdentity interfaces. These interfaces describe aspects of the current user that are independent of a specific authentication and authorization architecture. Implementers of the interfaces define how the user should be authenticated and what roles the user is currently enrolled in. This sample provides a very basic implementation of the IPrincipal and IIdentity interfaces to demonstrate how My.User can be configured to use developer-defined authorization and authentication mechanisms, respectively.

    Security noteSecurity Note:

    The implementation in this sample does not demonstrate secure coding practices. If the user types "password" for the password, the user is authenticated.

  • Authentication mode   The behavior of the program is controlled by the authentication mode. Open the Project Designer by double-clicking the My Project node in Solution Explorer. In the Application tab, Application-defined is selected for the Authentication Mode. When you run the application, the Login form will be displayed.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2015 Microsoft