Database.EnumObjectPermissions Database.EnumObjectPermissions Database.EnumObjectPermissions Method

Definition

Enumerates a list of permissions for objects in the database.

Overloads

EnumObjectPermissions(String, ObjectPermissionSet) EnumObjectPermissions(String, ObjectPermissionSet) EnumObjectPermissions(String, ObjectPermissionSet)

Enumerates a list of permissions for objects in the database that belong to the specified user and limited to the specified permission set.

EnumObjectPermissions(String) EnumObjectPermissions(String) EnumObjectPermissions(String)

Enumerates a list of permissions for objects in the database that belong to the specified user.

EnumObjectPermissions(ObjectPermissionSet) EnumObjectPermissions(ObjectPermissionSet) EnumObjectPermissions(ObjectPermissionSet)

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

EnumObjectPermissions() EnumObjectPermissions() EnumObjectPermissions()

Enumerates a list of permissions for objects in the database.

EnumObjectPermissions(String, ObjectPermissionSet) EnumObjectPermissions(String, ObjectPermissionSet) EnumObjectPermissions(String, ObjectPermissionSet)

Enumerates a list of permissions for objects in the database that belong to the specified user and limited to the specified permission set.

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

A String value that specifies the user who is the owner of the objects.

permissions
ObjectPermissionSet ObjectPermissionSet ObjectPermissionSet

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

Returns

An array of ObjectPermissionInfo objects that contains a list of permissions for the specified owner and permission set.

Examples

The example shows the EnumServerPermissions method, which is used like the EnumObjectPermissions 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)  

EnumObjectPermissions(String) EnumObjectPermissions(String) EnumObjectPermissions(String)

Enumerates a list of permissions for objects in the database that belong to the specified user.

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

A String value that specifies the user who is the owner of the objects.

Returns

An array of ObjectPermissionInfo objects that contains a list of object permissions for the specified owner.

Examples

The example shows the EnumServerPermissions method, which is used like the EnumObjectPermissions 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)  

EnumObjectPermissions(ObjectPermissionSet) EnumObjectPermissions(ObjectPermissionSet) EnumObjectPermissions(ObjectPermissionSet)

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

public:
 cli::array <Microsoft::SqlServer::Management::Smo::ObjectPermissionInfo ^> ^ EnumObjectPermissions(Microsoft::SqlServer::Management::Smo::ObjectPermissionSet ^ permissions);
public Microsoft.SqlServer.Management.Smo.ObjectPermissionInfo[] EnumObjectPermissions (Microsoft.SqlServer.Management.Smo.ObjectPermissionSet permissions);
Public Function EnumObjectPermissions (permissions As ObjectPermissionSet) As ObjectPermissionInfo()
Parameters
permissions
ObjectPermissionSet ObjectPermissionSet ObjectPermissionSet

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

Returns

An array of ObjectPermissionInfo objects that contains a list of object permissions for the database.

Examples

The example shows the EnumServerPermissions method, which is used like the EnumObjectPermissions 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)  

EnumObjectPermissions() EnumObjectPermissions() EnumObjectPermissions()

Enumerates a list of permissions for objects in the database.

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

An array of ObjectPermissionInfo objects that contains a list of object permissions for the database.

Examples

The example shows the EnumServerPermissions method, which is used like the EnumObjectPermissions 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