View comments | RSS feed

IsUserInRole

Description

Determines whether an authenticated user belongs to the specified Role.

Returns

True, if the authenticated user, belongs to the specified Role; False, otherwise.

Category

Security functions, Decision functions

Function syntax

IsUserInRole("role_name")

See also

GetAuthUser, cflogin, cfloginuser; Securing Applications in ColdFusion MX Developer's Guide

History

ColdFusion MX: Added this function.

Parameters

Parameter Description

role_name

Name of a security role

Usage

Role names are not case-sensitive.

To check if a user is in multiple roles, specify them in a comma-delimited list, such as "Admin,HR". Lists with multiple roles cannot contain spaces as separators; for example, do not use "Admin, HR".

Example

<cfif IsUserInRole("Admin") > 
   <cfoutput>Authenticated user is an administrator</cfoutput> 
<cfelse IsUserInRole("User") > 
   <cfoutput>Authenticated user is a user</cfoutput> 
</cfif>

ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | KnowledgeBase | Bug Reporting

Version 7

Comments


No screen name said on Apr 14, 2006 at 9:35 AM :
The example for the IsUserInRole has incorrect syntax on the cfelse, it should be a cfelseif.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/7/htmldocs/00000533.htm