Export (0) Print
Expand All

ServerConnection.IsInFixedServerRole Method

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

Namespace:  Microsoft.SqlServer.Management.Common
Assembly:  Microsoft.SqlServer.ConnectionInfo (in Microsoft.SqlServer.ConnectionInfo.dll)

public bool IsInFixedServerRole(
	FixedServerRoles fixedServerRole
)

Parameters

fixedServerRole
Type: Microsoft.SqlServer.Management.Common.FixedServerRoles
A FixedServerRoles() object value that specifies the fixed server role to be compared with the logon.

Return Value

Type: 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 = "AdventureWorks2008R2";
Console.WriteLine(conn.IsInFixedServerRole(FixedServerRoles.SysAdmin));

PowerShell

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

Community Additions

ADD
Show:
© 2014 Microsoft