共用方式為


ServerConnection.IsInFixedServerRole 方法

Tests whether the logon associated with the referenced connection is a member of the specified fixed server role.

命名空間:  Microsoft.SqlServer.Management.Common
組件:  Microsoft.SqlServer.ConnectionInfo (在 Microsoft.SqlServer.ConnectionInfo.dll 中)

語法

'宣告
Public Function IsInFixedServerRole ( _
    fixedServerRole As FixedServerRoles _
) As Boolean
'用途
Dim instance As ServerConnection 
Dim fixedServerRole As FixedServerRoles 
Dim returnValue As Boolean 

returnValue = instance.IsInFixedServerRole(fixedServerRole)
public bool IsInFixedServerRole(
    FixedServerRoles fixedServerRole
)
public:
bool IsInFixedServerRole(
    FixedServerRoles fixedServerRole
)
member IsInFixedServerRole : 
        fixedServerRole:FixedServerRoles -> bool
public function IsInFixedServerRole(
    fixedServerRole : FixedServerRoles
) : boolean

參數

傳回值

型別:System.Boolean
A Boolean value that specifies whether the logon is a member of the specified fixed server role.If True, the logon is a member of the specified fixed server role.If False, the logon is not a member of the specified fixed server role.

範例

C#

ServerConnection conn = new ServerConnection();
conn.DatabaseName = "AdventureWorks2012";
Console.WriteLine(conn.IsInFixedServerRole(FixedServerRoles.SysAdmin));

PowerShell

$conn = new-object Microsoft.SqlServer.Management.Common.ServerConnection
$conn.DatabaseName = "AdventureWorks2012"
Write-Host $conn.IsInFixedServerRole([Microsoft.SqlServer.Management.Common.FixedServerRoles]::SysAdmin)

請參閱

參考

ServerConnection 類別

Microsoft.SqlServer.Management.Common 命名空間

其他資源

固定伺服器角色的權限 (Database Engine)