22.08.2013 Views

ColdFusion Developer's Guide

ColdFusion Developer's Guide

ColdFusion Developer's Guide

SHOW MORE
SHOW LESS

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

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

Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta<br />

Reviewing the code<br />

The following table describes the securitytest.cfm page CFML code and its function:<br />

Code Description<br />

<br />

Welcome #GetAuthUser()#!<br />

<br />

ALL Logged-in Users see this message.<br />

<br />

<br />

if (IsUserInRole("Human Resources"))<br />

WriteOutput("Human Resources members<br />

see this message.");<br />

if (IsUserInRole("Documentation"))<br />

WriteOutput("Documentation members see<br />

this message.");<br />

if (IsUserInRole("Sales"))<br />

WriteOutput("Sales members see this<br />

message.");<br />

if (IsUserInRole("Manager"))<br />

WriteOutput("Managers see this<br />

message.");<br />

if (IsUserInRole("Employee"))<br />

WriteOutput("Employees see this<br />

message.");<br />

if (IsUserInRole("Contractor"))<br />

WriteOutput("Contractors see this<br />

message.");<br />

<br />

Using an LDAP directory for security information<br />

LDAP directories are often used to store security information. The following example of a<br />

cflogin tag checks an LDAP directory to authenticate the user and retrieve the user’s roles.<br />

For more information on using LDAP directories with <strong>ColdFusion</strong>, see Chapter 25,<br />

“Managing LDAP Directories.”<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

Displays a welcome message that<br />

includes the user’s login ID.<br />

Displays this message in all cases.<br />

The page does not display until a<br />

user is logged in.<br />

Tests whether the user belongs to<br />

each of the valid roles. If the user is<br />

in a role, displays a message with<br />

the role name.<br />

The user sees one message per role<br />

to which he or she belongs.<br />

<br />

Implementing user security 485

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

Saved successfully!

Ooh no, something went wrong!