Xbasic

A5_HAS_PERMISSION Function

Syntax

Result_Flag as L = a5_has_permission(C name ,C class ,C permission [,L lUI [,C user_name [,C master_password ]]])

Arguments

Result_Flag

.T. = The specified user has the indicated permission to the object. .F. = The user does not have the indicated permission.

name

The name of the object and the data dictionary that contains it.

class

The type of object for which you are changing permissions. Valid values are:

Object Class (Filename Extension of Data Dictionary used in Name parameter)
"Table" (table name)
"Form" (.DDD or .SET)
"Browse" (.DDD or .SET)
"Report" (.DDD or .SET)
"Letter" (.DDD or .SET)
"Label" (.DDD or .SET)
"Function" (.ALB)
"Script" (.ALB)
"Menu" (.ALB)
"Toolbar" (.ALB)
"Append records" (.DDD or .SET)
"Convert case of fields" (.DDD or .SET)
"Crosstab" (.DDD or .SET)
"Delete/Mark/Unmark records" (.DDD or .SET)
"Export records" (.DDD or .SET)
"Import records" (.ALB)
"Intersect/Join/Subtract records" (.DDD or .SET)
"Post records" (.DDD or .SET)
"Query records" (.DDD or .SET)
"Search and replace" (.DDD or .SET)
"Update records" (.DDD or .SET)
permission

The permission that is being changed. Valid values are:

Sets
>
"Default browse"
"Default form"
"Delete"
"Design"
"Drop"
Tables
>
"Change records"
"Default browse"
"Default form"
"Delete records"
"Enter records"
"View records"
All Other Objects
>
"Delete"
"Design"
"Delete"
"Design"
"Run"
lUI

Logical. Whether to display a message if permission is denied. Possible values are: .T. = Display a message. .F. = Do not display a message.

user_name

Optional. The default is the current user.

master_password

Optional. The master password for the database.

Description

Returns whether a user has access to an object

Discussion

The A5_HAS_PERMISSION() function tests whether a user has the specified permission to an object.

Example 

The following will check security and return true or false based on whether the current user has access to an object or not. It will display a message if permission is denied, since the fourth parameter is true.

? a5_has_permission("customer information at customer.ddd", "form", "run", .T.)
= .F.

The following will check the security db, but for the SPECIFIED user (Ed). The last parameter is the master database password (i.e. administrator password).

? a5_has_permission("customer information at customer.ddd", "form", "Run", .f., "Ed", "alpha")
= .F.

Limitations

Desktop applications only.

See Also