Home > Articles > Home & Office Computing > Entertainment/Gaming/Gadgets

  • Print
  • + Share This
From the author of Implementing Authentication

Implementing Authentication

The HTML client supports authentication. For instance, you can use Forms authentication so that the user must enter username and password to access data. Unlike the Silverlight client, which is a full-featured client, the HTML client doesn't have an administration page, which makes sense because it's designed for mobile devices. The assumption is that administration is handled on desktop workstations at the headquarters office. In other words, the HTML client allows for entering credentials in order to access data, but it doesn't allow you to create and administer users—you still need the Silverlight client for that.

Follow these steps to implement authentication:

  1. In Solution Explorer, double-click Properties.
  2. Select the Access Control tab, and then select the Forms authentication in the project properties.
  3. In Solution Explorer, right-click the project name and select Add Client.
  4. In the Add Client dialog, supply a name for the Silverlight desktop client, such as OrdersManagement (see Figure 13).
  5. Figure 13 Adding the Silverlight client to the solution.

  6. The Silverlight client is added to the desktop. You can add screens and implement logic as you like, but the goal here is to use this client only for administration purposes, so we don't actually need to add any screens. For this reason, simply publish the solution.
  7. In the Publish Wizard, specify all the required information and publish the application when ready. (Visit the official MSDN page if you need help with deployment.) In particular, supply the application's administrator credentials that will be used to administer users and roles (see Figure 14).

Figure 14 Supplying credentials for the application's administrator.

After you've published the application, you can use the Administration screen to create and manage users, as shown in Figure 15.

Figure 15 Creating users.

The administration screen basically allows you to create users and assign a password that can be changed later (but still in the Silverlight client, not the HTML client). If you try to open the HTML client in your web browser at this point, a login page appears, asking you to enter your username and password (see Figure 16).

Figure 16 Login page in the HTML client.

A user will be able to access the application only by entering valid credentials; otherwise, a validation error appears. Once the user has logged in, a Log Out button appears in the upper-right corner of the page. It's important for the user to click this button after using the application, so that the web session is terminated properly.

This is the simplest way to implement authentication for the HTML client. If you want to implement authentication directly in the HTML client, you'd need to use complex APIs and write tons of lines of JavaScript code. If you're not an expert, you might prefer to follow the steps described in this article.

If you've worked with the Silverlight client, you know how easy it is to define permissions, which allows you to restrict users to accessing specific sets of data and features. Again, the HTML client doesn't offer the same infrastructure by default. However, the LightSwitch team's Beth Massi has published a blog post that describes a possible alternative to implementing permissions in the HTML client.

  • + Share This
  • 🔖 Save To Your Account