CData Virtuality Server には、permissionsを設定するための特別な手順があります。Permissionは新しいセッション(СData Virtuality Studio、SquirreL などの新しいタブ)にのみ適用され、すでに作成されたセッション(すでに開いているタブ)には適用されないことに注意してください。

SYSADMIN.setPermissions

SYSADMIN.setPermissions(<IN string role_name>, <IN string resourceName>, <IN string permissions>, <IN string resourceType>, <IN string condition>, <IN boolean isConstaint>, <IN string mask>, <IN integer maskOrder>, <IN string mapToRole>)

Mandatory Parameters

resourceName/permissionsmapToRoleパラメータを同時に適用することはできません。mapToRolerole_nameパラメータにのみ使用できます。 resourceName/permissionsまたはmapToRoleのいずれかを使用してください。 

Parameter

Description

role_name

Role name

resourceName

Any resource path, e.g. "model", "model.table", or "model.table.column". resourceName could include a resource type prefix. Resource type prefix supported values are: table, view, procedure, function, job. For jobs a 'job:job_name' notation should be used.

permissions

Consists of the first letters of all available types of permissions (CREATE, READ, UPDATE, DELETE, EXECUTE, ALTER, LANGUAGE).
To delete a particular permission setting created earlier, pass NULL to the permissions parameter

mapToRole

Role name to be mapped to. 

  • Only an SSO role can be mapped to a CData Virtuality role. An SSO role cannot be mapped to an SSO role, and a CData Virtiuality role cannot be mapped to a СData Virtuality role;
  • Role can be mapped to another role only if this role_name role does not have any permissions assigned;
  • Resource permissions cannot be assigned to a role if this role is already mapped to another role;
  • To remove a role mapping, you need to map the role to an empty string to clear the existing mapping by calling setPermissions with mapToRole => ''

mapToRole parameter is available since v4.2

Optional Parameters

オプションの4つの文字列を使うと、row-based security settings and column masking を使用できます。

Parameter

Description

resourceType

Type of the resource.  Supported values: table, view, procedure, function, job

condition

Defines row-based security condition

isConstraint

Defines if values will be inserted/updated if the new value matches permission condition (TRUE) or all values will be inserted/updated (FALSE)

mask

Defines column mask value

maskOrder

Defines mask order if there are several masks for one column

resourceType parameter and resource type prefixes available since v4.9

Examples

1. ロールexample_roleのすべてのリソースにCRUDEAL Permissions を割り当てます:

CALL SYSADMIN.setPermissions("role_name" => 'example_role', "resourceName" => '*', "permissions" => 'CRUDEAL')

2. SSO ロールexample_role@SSOをData Virtuality admin-roleにマッピングします:

CALL SYSADMIN.setPermissions("role_name" => 'example_role@SSO', "mapToRole" => 'admin-role')

すべてのPermissionはSYSADMIN.Permissionsテーブルに保存され、admin ユーザーと、このテーブルのPermissionを持つすべてのユーザーがアクセスできます。

SYSADMIN.hasPermission

このプロシージャは、あるユーザがあるリソースに対して特定の Permission を持っているかどうかを調べるために使われます。

SYSADMIN.hasPermission(<IN string username>, <IN string resource>, <IN string permissions>)

Parameters

Parameter

Description

username

User name

resource

Any resource path, e.g. "model", "model.table", or "model.table.column". For a job a 'job:job_name' notation should be used

permissions

Consists of the first letters of all available types of permissions (CREATE, READ, UPDATE, DELETE, EXECUTE, ALTER, LANGUAGE)

以下は、test_user がREAD viewsのPermission を持っているかどうかを調べる例です:

CALL SYSADMIN.hasPermissions('test_user', 'views', 'R')

SYSADMIN.hasPermission procedure is available since v4.1

SYSADMIN.changeResourceOwnerAndExecutor

このプロシージャは、リソースの所有者や実行者といったPermission を変更するために使用されます。現在、プロシージャ、ジョブ、スケジュールをサポートしています。

SYSADMIN.changeResourceOwnerAndExecutor(<IN string name>, <IN string uuid>, <IN string resourceType>, <IN string owner>, <IN string executeAs>)

 name または uuid (for jobs and schedules) パラメータ、またはその両方を指定する必要があります。

Parameters

Parameter

Description

name

Resource name

uuid

UUID of resource, valid only for jobs and schedules

resourceType

Type of resource, field is mandatory, case-insensitive. Supported values are: PROCEDURE, JOB, SCHEDULE

owner

Name of the resource owner needs to be set. Owner could be set to a value that is not equal to the current user only by members of admin-role

executeAs

Resource runner/executor (executeAs for procedures, runAs for jobs, for schedules it is not supported). Allowed values: CALLER and OWNER

以下は、ユーザー u1 をジョブtest1のオーナーに設定する例です:

CALL "SYSADMIN.changeResourceOwnerAndExecutor"(
"name" => 'test1',
"resourceType" => 'job',
"owner" => 'u1'
);;

SYSADMIN.changeResourceOwnerAndExecutor procedure available since v4.5

SYSADMIN.copyPermissions

このプロシージャは、権限をロールにコピーするために使用されます。

SYSADMIN.copyPermissions(<IN string sourceRoles>, <IN string permissionIds>, <IN string targetRole>, <IN boolean createRoleIfNotExist>)

sourceRolespermissionIdsパラメータは、別々に指定することも、一緒に指定することもできます。

Parameters

Parameter

Description

sourceRoles

Source roles (comma-separated) whose permissions will be copied to the target role

permissionIds

IDs of permissions (comma-separated) that will be copied to the target role

targetRole

The target role to which the permissions will be copied

createRoleIfNotExist

If set to TRUE, the target role will be created if it does not exist. Default: FALSE

コピー元のロールまたはコピー元のパーミッションが同じオブジェクトに対して異なるパーミッションを持つ場合、コピーされたパーミッションは結合されます。コピーされた結合されたパーミッションと共にSQL警告がサーバーログに表示されます。

Examples

1. ロールtest_role1およびtest_role2からロールtarget-role2に権限をコピーし、target-role2が存在しない場合は作成します:

CALL "SYSADMIN.copyPermissions"("sourceRoles" => 'test_role1,test_role2', "targetRole" => 'target-role2', "createRoleIfNotExist" => true);;

2. ID が8185の権限をロールtarget-role1にコピーし、target-role1が存在しない場合は作成します:

CALL "SYSADMIN.copyPermissions"("permissionIds" => '81,85', "targetRole" => 'target-role1', "createRoleIfNotExist" => true);;

3. ID が8185で、ロールtest-role1から既存のロールtarget-role3に権限をコピーします:

CALL "SYSADMIN.copyPermissions"("sourceRoles" => 'test_role1', "permissionIds" => '81,85', "targetRole" => 'target-role3');;

SYSADMIN.copyPermissions procedure is available since v4.10