Server.EnumServerPermissions Server.EnumServerPermissions Server.EnumServerPermissions Method

Definition

Enumerates a list of server permissions for the instance of SQL Server.

Overloads

EnumServerPermissions(String, ServerPermissionSet) EnumServerPermissions(String, ServerPermissionSet) EnumServerPermissions(String, ServerPermissionSet)

Enumerates a list of server permissions for a specified grantee and a specified permission on the instance of SQL Server.

EnumServerPermissions(String) EnumServerPermissions(String) EnumServerPermissions(String)

Enumerates a list of server permissions for a specified grantee on the instance of SQL Server.

EnumServerPermissions() EnumServerPermissions() EnumServerPermissions()

Enumerates a list of server permissions for the instance of SQL Server.

EnumServerPermissions(ServerPermissionSet) EnumServerPermissions(ServerPermissionSet) EnumServerPermissions(ServerPermissionSet)

Enumerates a list of server permissions for a specified permission on the instance of SQL Server.

Remarks

Use this method to return an array of ServerPermissionInfo objects that contain information about the permissions currently set on the instance of SQL Server.

EnumServerPermissions(String, ServerPermissionSet) EnumServerPermissions(String, ServerPermissionSet) EnumServerPermissions(String, ServerPermissionSet)

Enumerates a list of server permissions for a specified grantee and a specified permission on the instance of SQL Server.

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

A String value that specifies the grantee.

permissions
ServerPermissionSet ServerPermissionSet ServerPermissionSet

A ServerPermissionSet object value that specifies the permission.

Returns

An array of ServerPermissionInfo objects that contains server permission information for the specified grantee and permission on the instance of SQL Server.

Examples

Visual Basic

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)  

Remarks

Use this method to return an array of ServerPermissionInfo objects that contain information about the permissions currently set on the instance of SQL Server for the specified grantee and for the given set of permissions.

EnumServerPermissions(String) EnumServerPermissions(String) EnumServerPermissions(String)

Enumerates a list of server permissions for a specified grantee on the instance of SQL Server.

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

A String value that specifies the grantee.

Returns

An array of ServerPermissionInfo objects that contains server permission information for the specified grantee on the instance of SQL Server.

Examples

Visual Basic

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)  

Remarks

Use this method to return an array of ServerPermissionInfo objects that contain information about the permissions currently set on the instance of SQL Server for the specified grantee.

EnumServerPermissions() EnumServerPermissions() EnumServerPermissions()

Enumerates a list of server permissions for the instance of SQL Server.

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

An array of ServerPermissionInfo objects that contains server permission information for the instance of SQL Server.

Examples

Visual Basic

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)  

Remarks

Use this method to return an array of ServerPermissionInfo objects that contain information about the permissions currently set on the instance of SQL Server.

EnumServerPermissions(ServerPermissionSet) EnumServerPermissions(ServerPermissionSet) EnumServerPermissions(ServerPermissionSet)

Enumerates a list of server permissions for a specified permission on the instance of SQL Server.

public:
 cli::array <Microsoft::SqlServer::Management::Smo::ServerPermissionInfo ^> ^ EnumServerPermissions(Microsoft::SqlServer::Management::Smo::ServerPermissionSet ^ permissions);
public Microsoft.SqlServer.Management.Smo.ServerPermissionInfo[] EnumServerPermissions (Microsoft.SqlServer.Management.Smo.ServerPermissionSet permissions);
Public Function EnumServerPermissions (permissions As ServerPermissionSet) As ServerPermissionInfo()
Parameters
permissions
ServerPermissionSet ServerPermissionSet ServerPermissionSet

A ServerPermissionSet value that specifies the permission.

Returns

An array of ServerPermissionInfo objects that contains server permission information for the specified permission on the instance of SQL Server.

Examples

Visual Basic

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)  

Remarks

Use this method to return an array of ServerPermissionInfo objects that contain information about the permissions currently set on the instance of SQL Server for the given set of permissions.

Applies to