次の方法で共有


Server.Grant Method (ServerPermissionSet, String[], Boolean, String)

権限許可対象ユーザーに対し、指定した権限のセットと、想定したロールに基づいて Microsoft SQL Server のインスタンスの他のユーザーにその権限のセットを許可する権限を許可します。

名前空間: Microsoft.SqlServer.Management.Smo
アセンブリ: Microsoft.SqlServer.Smo (microsoft.sqlserver.smo.dll 内)

構文

'宣言
Public Sub Grant ( _
    permission As ServerPermissionSet, _
    granteeNames As String(), _
    grantGrant As Boolean, _
    asRole As String _
)
public void Grant (
    ServerPermissionSet permission,
    string[] granteeNames,
    bool grantGrant,
    string asRole
)
public:
void Grant (
    ServerPermissionSet^ permission, 
    array<String^>^ granteeNames, 
    bool grantGrant, 
    String^ asRole
)
public void Grant (
    ServerPermissionSet permission, 
    String[] granteeNames, 
    boolean grantGrant, 
    String asRole
)
public function Grant (
    permission : ServerPermissionSet, 
    granteeNames : String[], 
    grantGrant : boolean, 
    asRole : String
)

パラメータ

  • granteeNames
    権限のセットを許可する権限許可対象ユーザーの一覧を示す String 配列です。
  • grantGrant
    権限許可対象ユーザーに対し、Microsoft SQL Server のインスタンスの他のユーザーに権限のセットを許可する権限を許可するかどうかを示す Boolean プロパティです。

    True の場合は、権限許可対象ユーザーに対し、指定した権限のセットを Microsoft SQL Server のインスタンスの他のユーザーに許可する権限を許可します。

    False の場合は、権限許可対象ユーザーに対し、指定した権限のセットを Microsoft SQL Server のインスタンスの他のユーザーに許可する権限を許可しません。

  • asRole
    指定した権限のセットを Microsoft SQL Server のインスタンスの他のユーザーに許可するときに、ユーザーが想定するロールを示す String 値です。複数のロールのメンバである権限許可対象ユーザーに対しては、このパラメータを使用します。

解説

更新されたテキスト :

この名前空間、クラス、またはメンバは、Microsoft .NET Framework Version 2.0 でのみサポートされています。

使用例

'Connect to the local, default instance of SQL Server.
Dim svr As Server
svr = New Server()
'Define a ServerPermissionSet that contains permission to Create Endpoint and Alter Any Endpoint.
Dim sps As ServerPermissionSet
sps = New ServerPermissionSet(ServerPermission.CreateEndpoint)
sps.Add(ServerPermission.AlterAnyEndpoint)
'This sample assumes that the grantee already has permission to Create Endpoints. 
'Enumerate and display the server permissions in the set for the grantee specified in the vGrantee string variable.
Dim spis As ServerPermissionInfo()
spis = svr.EnumServerPermissions(vGrantee, sps)
Dim spi As ServerPermissionInfo
Console.WriteLine("=================Before revoke===========================")
For Each spi In spis
    Console.WriteLine(spi.Grantee & " has " & spi.PermissionType.ToString & " permission.")
Next
Console.WriteLine(" ")
'Remove a permission from the set.
sps.Remove(ServerPermission.CreateEndpoint)
'Revoke the create endpoint permission from the grantee.
svr.Revoke(sps, vGrantee)
'Enumerate and display the server permissions in the set for the grantee specified in the vGrantee string variable.
spis = svr.EnumServerPermissions(vGrantee, sps)
Console.WriteLine("=================After revoke============================")
For Each spi In spis
    Console.WriteLine(spi.Grantee & " has " & spi.PermissionType.ToString & " permission.")
Next
Console.WriteLine(" ")
'Grant the Create Endpoint permission to the grantee.
svr.Grant(sps, vGrantee)
'Enumerate and display the server permissions in the set for the grantee specified in the vGrantee string variable.
spis = svr.EnumServerPermissions(vGrantee, sps)
Console.WriteLine("=================After grant=============================")
For Each spi In spis
    Console.WriteLine(spi.Grantee & " has " & spi.PermissionType.ToString & " permission.")
Next
Console.WriteLine("")

スレッド セーフ

この型の public static (Microsoft Visual Basic では共有 ) メンバは、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。

プラットフォーム

開発プラットフォーム

サポートされているプラットフォームの一覧については、「SQL Server 2005 のインストールに必要なハードウェアおよびソフトウェア」を参照してください。

対象プラットフォーム

サポートされているプラットフォームの一覧については、「SQL Server 2005 のインストールに必要なハードウェアおよびソフトウェア」を参照してください。

参照

関連項目

Server Class
Server Members
Microsoft.SqlServer.Management.Smo Namespace

その他の技術情報

Visual Basic .NET でサーバー権限を許可する方法
権限の許可、取り消し、および拒否
サーバーの管理

変更履歴

リリース

履歴

新しい内容 :
  • 「例」セクションにコード サンプルを追加しました。