The AspNetLoginControl

Example B-3 shows the definition of AspNetLoginControl.

Example B-3. The AspNetLoginControl class

public partial class AspNetLoginControl : LoginControl
{
   protected override IUserManager GetUserManager()
   {
      return new AspNetUserManager();
   }
}

AspNetLoginControl derives from LoginControl, and in its overriding of GetUserManager() it returns the AspNetUserManager implementation of IUserManager, which uses the ASP.NET providers directly (see Figure B-4).

AspNetUserManager is capable of using any valid ASP.NET 2.0 provider (hence its name). To use AspNetLoginControl, you will need to add to the application’s configuration file the same values you would have placed in a web application configuration file, indicating which provider to choose as well as any provider-specific values and settings.

For example, to use the SQL Server provider (which is the default provider), add the settings shown in Example B-4 to the application configuration file. The connection string value shown in Figure B-4 is used to connect to the aspnetdb database on the local machine after default installation. Note the use of the enabled attribute of the roleManager tag to enable authorization.

The AspNetLoginControl control

Figure B-4. The AspNetLoginControl control

Example B-4. Settings for AspNetLoginControl

<?xml version="1.0"?> <configuration> <system.web> <roleManager enabled="true"/> </system.web> <connectionStrings> <remove ...

Get Programming .NET Components, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.