Determines whether an authenticated user belongs to the specified Role.
True, if the authenticated user, belongs to the specified Role; False, otherwise.
IsUserInRole("role_name")
cflogin, cfloginuser, GetAuthUser, GetUserRoles, IsUserInAnyRole, IsUserLoggedIn, Securing Applications in the Developing ColdFusion Applications
ColdFusion MX: Added this function.
Parameter |
Description |
|---|---|
role_name |
Name of a security role |
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".
<cfif IsUserInRole("Admin") >
<cfoutput>Authenticated user is an administrator</cfoutput>
<cfelse IsUserInRole("User") >
<cfoutput>Authenticated user is a user</cfoutput>
</cfif>
From ColdFusion 11 onwards, this function is not applicable when a user is logged in using Admin API.
Sign in to your account