15.02.2015 Views

C# 4 and .NET 4

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

security ❘ 1201<br />

<br />

<br />

You are currently logged in as<br />

.<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

code snippet PCSDemoSite/MasterPage.master<br />

The only point to note here is that CSS classes are supplied for both SiteMapPath <strong>and</strong> TreeView, to<br />

facilitate theming (discussed later in this chapter).<br />

seCuriTy<br />

Security <strong>and</strong> user management have often been seen as quite complicated to implement in web sites, <strong>and</strong><br />

with good reason. You have to consider a number of factors, including:<br />

➤<br />

➤<br />

➤<br />

➤<br />

➤<br />

What sort of user management system will I implement Will users map to Windows user accounts, or<br />

will I implement something independent<br />

How do I implement a login system<br />

Do I let users register on the site; if so, how<br />

How do I let some users see <strong>and</strong> do only some things, while supplying other users with additional<br />

privileges<br />

What happens in the case of forgotten passwords<br />

With ASP.<strong>NET</strong>, you have a whole suite of tools at your disposal for dealing with questions such as these,<br />

<strong>and</strong> it can in fact take only a matter of minutes to implement a user system on your site. You have three<br />

types of authentication at your disposal:<br />

➤<br />

➤<br />

➤<br />

Windows Authentication, whereby users have Windows accounts, typically used with intranet sites or<br />

Wide Area Network (WAN) portals<br />

Forms Authentication, whereby the web site maintains its own list of users <strong>and</strong> h<strong>and</strong>les its own<br />

authentication<br />

Microsoft Live ID Authentication (formerly known as Passport authentication), whereby Microsoft<br />

provides a centralized authentication service for you to use<br />

A full discussion of security in ASP.<strong>NET</strong> would take up at least a full chapter, but we provide a brief look in<br />

this section to give you an idea of how things work. You concentrate on Forms Authentication here, because<br />

it is the most versatile system <strong>and</strong> very quick to get up <strong>and</strong> running.<br />

The quickest way to implement Forms Authentication is via the web site ASP.<strong>NET</strong> Configuration tool, which<br />

you saw briefly in the previous chapter. This tool has a Security tab, <strong>and</strong> on it a Security Setup Wizard. This<br />

wizard lets you choose an authentication type, add roles, add users, <strong>and</strong> secure areas of your site.<br />

adding forms authentication using the security setup Wizard<br />

For the purposes of this explanation, create a new empty web site called PCSAuthenticationDemo in the<br />

directory C:\ProCSharp\Chapter41\. After you create the site, configure security using the following<br />

example steps:<br />

1. Open the web site ASP.<strong>NET</strong> Configuration tool.<br />

2. Navigate to the Security tab.<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!