Object Permission Resource
Synopsis
Manages SQL Server object-level permissions on tables, views, stored procedures, and other database objects. Supports Grant, Grant With Grant, and Deny states.
Type
Capabilities
- Get
- Set
- Delete
- Export
Properties
serverInstance
SQL Server instance name.
connectUsername
Username for SQL authentication.
connectPassword
Password for SQL authentication.
databaseName
Name of the database.
schemaName
Schema of the object.
objectType
Type of database object. See Object types below.
objectName
Name of the database object.
principal
Name of the principal (user or role).
permission
Object permission. See Permissions below.
state
Permission state. Accepts Grant, GrantWithGrant, or Deny.
grantor
Grantor of the permission.
_exist
Whether the permission should exist.
Object types
| Value | Description |
|---|---|
Table |
Table |
View |
View |
StoredProcedure |
Stored procedure |
UserDefinedFunction |
User-defined function |
Schema |
Schema |
Sequence |
Sequence |
Synonym |
Synonym |
Permissions
| Value | Description |
|---|---|
Select |
Read data from the object |
Insert |
Insert data into the object |
Update |
Modify data in the object |
Delete |
Delete data from the object |
Execute |
Execute a stored procedure or function |
References |
Reference the object in a foreign key |
ViewDefinition |
View the object definition |
Alter |
Alter the object |
Control |
Full control over the object |
TakeOwnership |
Take ownership of the object |
Examples
Example 1 — Grant SELECT on a table
Example 2 — Grant EXECUTE on a stored procedure
Example 3 — Configuration document
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Grant select on Customers
type: OpenDsc.SqlServer/ObjectPermission
properties:
serverInstance: "."
databaseName: AppDb
objectType: Table
objectName: Customers
principal: AppUser
permission: Select
state: Grant
- name: Grant execute on stored procedure
type: OpenDsc.SqlServer/ObjectPermission
properties:
serverInstance: "."
databaseName: AppDb
objectType: StoredProcedure
objectName: usp_GetCustomers
principal: AppUser
permission: Execute
state: Grant
Exit codes
| Code | Description |
|---|---|
| 0 | Success |
| 1 | Error |
| 2 | Invalid JSON |
| 3 | Invalid argument |
| 4 | Unauthorized access |
| 5 | Invalid operation |