03.11.2016 Views

Beginning ASP.NET 4.5 in CSharp and VB Opsylum

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

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

The Role Manager x 631<br />

FIGURE 16-19<br />

From here you can edit, enable, disable, or delete exist<strong>in</strong>g users. For example, if you previously<br />

set DisableCreatedUser to True <strong>in</strong> the CreateUserWizard, you can enable the user here by<br />

check<strong>in</strong>g the check box <strong>in</strong> front of the username, visible <strong>in</strong> Figure 16-19. You can change the roles<br />

that are assigned to the user by click<strong>in</strong>g the Edit Roles l<strong>in</strong>k. Also, us<strong>in</strong>g the filter controls <strong>and</strong> the<br />

alphabet above the user list, you can quickly search for a specific user <strong>in</strong> case you’re deal<strong>in</strong>g with<br />

a lot of user accounts.<br />

9. To see where your user <strong>and</strong> role ended up, close the browser <strong>and</strong> go back to VS. On the Solution<br />

Explorer, double-click the PlanetWrox.mdf database <strong>in</strong> the App_Data folder to open it <strong>in</strong> the<br />

Database Explorer w<strong>in</strong>dow. Then exp<strong>and</strong> the Tables node, right-click the Roles table, <strong>and</strong> choose<br />

Show Table Data. The role you created <strong>in</strong> step 5 should be listed. Open up some of the other tables<br />

such as Memberships <strong>and</strong> UsersInRoles <strong>and</strong> <strong>in</strong>spect the data they conta<strong>in</strong>. In the first table, you<br />

should see the user account you created <strong>in</strong> steps 6 <strong>and</strong> 7, <strong>and</strong> the latter table conta<strong>in</strong>s a relationship<br />

between the new role <strong>and</strong> user account.<br />

How It Works<br />

Just like the log<strong>in</strong> controls, the WSAT eventually talks to the provider you configured <strong>in</strong><br />

the Web.config file. In the case of the Planet Wrox application, it means it talks to the<br />

DefaultMembershipProvider <strong>and</strong> the DefaultRoleProvider, which <strong>in</strong> turn talk to a SQL Server<br />

Express LocalDB database identified by your connection str<strong>in</strong>g. The users <strong>and</strong> roles you create<br />

are stored <strong>in</strong> various tables <strong>in</strong> the database. Users that you create us<strong>in</strong>g the WSAT end up <strong>in</strong> the<br />

exact same location as those created with the CreateUserWizard control. In fact, the WSAT uses a<br />

CreateUserWizard to create new user accounts. This means that any user you enter <strong>in</strong> the WSAT is<br />

able to log <strong>in</strong> us<strong>in</strong>g your st<strong>and</strong>ard Log<strong>in</strong>.aspx page. In a later exercise, you use the Manager account<br />

you created <strong>in</strong> this exercise to log <strong>in</strong> to the site <strong>and</strong> access the Management folder.

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

Saved successfully!

Ooh no, something went wrong!