Database.EnumDatabasePermissions Database.EnumDatabasePermissions Database.EnumDatabasePermissions Method

Definition

Enumerates a list of all database permissions in the database.

Overloads

EnumDatabasePermissions(String, DatabasePermissionSet) EnumDatabasePermissions(String, DatabasePermissionSet) EnumDatabasePermissions(String, DatabasePermissionSet)

Enumerates a list of permissions in the database for the specified user and a specified permission set.

EnumDatabasePermissions(String) EnumDatabasePermissions(String) EnumDatabasePermissions(String)

Enumerates a list of permissions in the database for the specified user.

EnumDatabasePermissions() EnumDatabasePermissions() EnumDatabasePermissions()

Enumerates a list of all permissions in the database.

EnumDatabasePermissions(DatabasePermissionSet) EnumDatabasePermissions(DatabasePermissionSet) EnumDatabasePermissions(DatabasePermissionSet)

Enumerates a list of permissions in the database for the specified permission set.

EnumDatabasePermissions(String, DatabasePermissionSet) EnumDatabasePermissions(String, DatabasePermissionSet) EnumDatabasePermissions(String, DatabasePermissionSet)

Enumerates a list of permissions in the database for the specified user and a specified permission set.

public:
 cli::array <Microsoft::SqlServer::Management::Smo::DatabasePermissionInfo ^> ^ EnumDatabasePermissions(System::String ^ granteeName, Microsoft::SqlServer::Management::Smo::DatabasePermissionSet ^ permissions);
public Microsoft.SqlServer.Management.Smo.DatabasePermissionInfo[] EnumDatabasePermissions (string granteeName, Microsoft.SqlServer.Management.Smo.DatabasePermissionSet permissions);
Public Function EnumDatabasePermissions (granteeName As String, permissions As DatabasePermissionSet) As DatabasePermissionInfo()
Parameters
granteeName
String String String

A String value that specifies the user.

permissions
DatabasePermissionSet DatabasePermissionSet DatabasePermissionSet

A DatabasePermissionSet object that limits the enumerated list to those listed.

Returns

An array of DatabasePermissionInfo object values that contains an enumerated list of permissions.

Examples

The example shows the EnumServerPermissions method. This is used like the EnumDatabasePermissions method.

VB

PowerShell

$srv = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")  
$arg = [Microsoft.SqlServer.Management.Smo.ServerPermission]::CreateEndpoint  

$sps = new-object Microsoft.SqlServer.Management.Smo.ServerPermissionSet([Microsoft.SqlServer.Management.Smo.ServerPermission]::CreateEndpoint)  
$sps.Add([Microsoft.SqlServer.Management.Smo.ServerPermission]::AlterAnyEndpoint)  
$spis = $srv.EnumServerPermissions("vGrantee", $sps)  
Write-Host "=================Before revoke==========================="  
Foreach ($spi In $spis)  
{  
   Write-Host $spi.Grantee "has" $spi.PermissionType " permission."  
}  
Write-Host " "  
$sps.Remove([Microsoft.SqlServer.Management.Smo.ServerPermission]::CreateEndpoint)  

EnumDatabasePermissions(String) EnumDatabasePermissions(String) EnumDatabasePermissions(String)

Enumerates a list of permissions in the database for the specified user.

public:
 cli::array <Microsoft::SqlServer::Management::Smo::DatabasePermissionInfo ^> ^ EnumDatabasePermissions(System::String ^ granteeName);
public Microsoft.SqlServer.Management.Smo.DatabasePermissionInfo[] EnumDatabasePermissions (string granteeName);
Public Function EnumDatabasePermissions (granteeName As String) As DatabasePermissionInfo()
Parameters
granteeName
String String String

A String value that specifies the user.

Returns

An array of DatabasePermissionInfo object values that contains an enumerated list of permissions.

Examples

The example shows the EnumServerPermissions method. This is used like the EnumDatabasePermssions method.

VB

PowerShell

$srv = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")  
$arg = [Microsoft.SqlServer.Management.Smo.ServerPermission]::CreateEndpoint  

$sps = new-object Microsoft.SqlServer.Management.Smo.ServerPermissionSet([Microsoft.SqlServer.Management.Smo.ServerPermission]::CreateEndpoint)  
$sps.Add([Microsoft.SqlServer.Management.Smo.ServerPermission]::AlterAnyEndpoint)  
$spis = $srv.EnumServerPermissions("vGrantee", $sps)  
Write-Host "=================Before revoke==========================="  
Foreach ($spi In $spis)  
{  
   Write-Host $spi.Grantee "has" $spi.PermissionType " permission."  
}  
Write-Host " "  
$sps.Remove([Microsoft.SqlServer.Management.Smo.ServerPermission]::CreateEndpoint)  

EnumDatabasePermissions() EnumDatabasePermissions() EnumDatabasePermissions()

Enumerates a list of all permissions in the database.

public:
 cli::array <Microsoft::SqlServer::Management::Smo::DatabasePermissionInfo ^> ^ EnumDatabasePermissions();
public Microsoft.SqlServer.Management.Smo.DatabasePermissionInfo[] EnumDatabasePermissions ();
Public Function EnumDatabasePermissions () As DatabasePermissionInfo()
Returns

An array of DatabasePermissionInfo object values that contains an enumerated list of permissions.

Examples

The example shows the EnumServerPermissions method. This is used like the EnumDatabasePermssions method.

VB

PowerShell

$srv = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")  
$arg = [Microsoft.SqlServer.Management.Smo.ServerPermission]::CreateEndpoint  

$sps = new-object Microsoft.SqlServer.Management.Smo.ServerPermissionSet([Microsoft.SqlServer.Management.Smo.ServerPermission]::CreateEndpoint)  
$sps.Add([Microsoft.SqlServer.Management.Smo.ServerPermission]::AlterAnyEndpoint)  
$spis = $srv.EnumServerPermissions("vGrantee", $sps)  
Write-Host "=================Before revoke==========================="  
Foreach ($spi In $spis)  
{  
   Write-Host $spi.Grantee "has" $spi.PermissionType " permission."  
}  
Write-Host " "  
$sps.Remove([Microsoft.SqlServer.Management.Smo.ServerPermission]::CreateEndpoint)  

EnumDatabasePermissions(DatabasePermissionSet) EnumDatabasePermissions(DatabasePermissionSet) EnumDatabasePermissions(DatabasePermissionSet)

Enumerates a list of permissions in the database for the specified permission set.

public:
 cli::array <Microsoft::SqlServer::Management::Smo::DatabasePermissionInfo ^> ^ EnumDatabasePermissions(Microsoft::SqlServer::Management::Smo::DatabasePermissionSet ^ permissions);
public Microsoft.SqlServer.Management.Smo.DatabasePermissionInfo[] EnumDatabasePermissions (Microsoft.SqlServer.Management.Smo.DatabasePermissionSet permissions);
Public Function EnumDatabasePermissions (permissions As DatabasePermissionSet) As DatabasePermissionInfo()
Parameters
permissions
DatabasePermissionSet DatabasePermissionSet DatabasePermissionSet

A DatabasePermissionSet object that limits the enumerated list to those listed.

Returns

An array of DatabasePermissionInfo object values that contains an enumerated list of permissions.

Examples

The example shows the EnumServerPermissions method. This is used like the EnumDatabasePermssions method.

VB

PowerShell

$srv = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")  
$arg = [Microsoft.SqlServer.Management.Smo.ServerPermission]::CreateEndpoint  

$sps = new-object Microsoft.SqlServer.Management.Smo.ServerPermissionSet([Microsoft.SqlServer.Management.Smo.ServerPermission]::CreateEndpoint)  
$sps.Add([Microsoft.SqlServer.Management.Smo.ServerPermission]::AlterAnyEndpoint)  
$spis = $srv.EnumServerPermissions("vGrantee", $sps)  
Write-Host "=================Before revoke==========================="  
Foreach ($spi In $spis)  
{  
   Write-Host $spi.Grantee "has" $spi.PermissionType " permission."  
}  
Write-Host " "  
$sps.Remove([Microsoft.SqlServer.Management.Smo.ServerPermission]::CreateEndpoint)  

Applies to