IsAuthorized

Returns TRUE if the user is authorized to perform the specified action on the specified ColdFusion resource.

See also IsAuthenticated.

Syntax

IsAuthorized(resourcetype, resourcename [, action ])
resourcetype

String specifying the type of resource:

resourcename

String specifying the name of the resource. The value specified varies depending on the resource type:

resourcetype specification resourcename specification
APPLICATION Application name
CFML CFML tag name
FILE File name
DATASOURCE Data source name
COMPONENT Component name
COLLECTION Verity collection name
CUSTOMTAG Custom tag name
USEROBJECT Object name

Resourcename is the actual resource that is protected, not to be confused with the rule name, which you specify in the ColdFusion Administrator.

action

String specifying the action for which authorization is requested. Do not specify this parameter for COMPONENT and CUSTOMTAG. For all other resource types, this parameter is required.

resourcetype specification Possible ACTIONs
APPLICATION ALL
USECLIENTVARIABLES
CFML Valid actions for the tag specified by resourcename
FILE READ
WRITE
DATASOURCE ALL
CONNECT
SELECT
INSERT
UPDATE
DELETE
SP (stored procedure)
COMPONENT No actions for this resource type
COLLECTION DELETE
OPTIMIZE
PURGE
SEARCH
UPDATE
CUSTOMTAG No actions for this resource type
USEROBJECT Action specified via the ColdFusion Administrator

Usage

If you specify THROWONFAILURE=Yes in the CFAUTHENTICATE tag, you can enclose IsAuthorized in a CFTRY/CFCATCH block to handle possible exceptions programmatically.

Example

<!---  This example calls the IsAuthorized
       function. --->
...
<!--- Is user is authorized to select information from the 
    Orders data source? --->
<CFIF IsAuthorized("DATASOURCE", "Orders", "select")>
   <CFQUERY NAME="GetList" datasource="Orders">
       SELECT *    FROM Orders
   </CFQUERY>
   <CFOUTPUT QUERY="GetList">
       Authorization Succeeded. Order information follows:
       #Customer# - #BalanceDue#<BR>
    </CFOUTPUT>
</CFIF>

</BODY>
</HTML>       



1