ListDatabasePermissions Method (SQL-DMO)

The ListDatabasePermissions method returns a SQLObjectList object enumerating database maintenance privilege for one or more Microsoft® SQL Server™ security accounts.

Applies To
Database Object User Object
DatabaseRole Object  

Syntax

object.ListDatabasePermissions( [ Privilege ] ) as SQLObjectList

Part Description
object Expression that evaluates to an object in the Applies To list.
Privilege Optional. Constrains the list to members enumerating database maintenance statement permissions as described in Settings.

Settings

When setting the Privilege argument to override default behavior, indicate more than a single statement execution permission by combining values using an Or.

Constant Value Description
SQLDMOPriv_AllDatabasePrivs 65408 Default. List object enumerates all database maintenance statement execution permissions.
SQLDMOPriv_CreateDatabase 256 List object enumerates accounts granted permission to execute the CREATE DATABASE statement.
SQLDMOPriv_CreateDefault 4096 List object enumerates accounts granted permission to execute the CREATE DEFAULT statement.
SQLDMOPriv_CreateProcedure 1024 List object enumerates accounts granted permission to execute the CREATE PROCEDURE statement.
SQLDMOPriv_CreateRule 16384 List object enumerates accounts granted permission to execute the CREATE RULE statement.
SQLDMOPriv_CreateTable 128 List object enumerates accounts granted permission to execute the CREATE TABLE statement.
SQLDMOPriv_CreateView 512 List object enumerates accounts granted permission to execute the CREATE VIEW statement.
SQLDMOPriv_DumpDatabase 2048 List object enumerates accounts with privilege required to backup a database.
SQLDMOPriv_DumpTransaction 8192 List object enumerates accounts with privilege required to backup a database transaction log.

Returns

A SQLObjectList object containing 0 or more Permission objects.

Remarks

The ListDatabasePermissions method enumerates statement execution permission explicitly granted, and is maintained for compatibility with previous versions of SQL Server.

SQL Server server and database roles assign privilege by implicitly granting statement execution permissions. Implicit grants are not enumerated by the ListDatabasePermissions method.

For example, a user may be a member of the db_backupoperator role. The user has permission to execute a Transact-SQL BACKUP statement targeting either the database or its transaction log. The user will not be enumerated by the ListDatabasePermissions method as the grant is implicit in the role.

Prototype (C/C++)

HRESULT ListDatabasePermissions(
LPSQLDMOPERMISSIONLIST* ppList,
SQLDMO_PRIVILEGE_TYPE lPrivilegeTypes = SQLDMOPriv_AllDatabasePrivs);

  


(c) 1988-98 Microsoft Corporation. All Rights Reserved.