次の方法で共有


Database.Revoke Method (DatabasePermissionSet, String, Boolean, Boolean, String)

データベースの権限許可対象ユーザーと、指定した権限セットをその権限許可対象ユーザーから許可された他のすべてのユーザーから、以前に許可した権限を取り消します。また、権限許可対象ユーザーに対し、指定した権限セットを想定したロールに基づいて他のユーザーから取り消す権限を付与します。

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

構文

'宣言
Public Sub Revoke ( _
    permission As DatabasePermissionSet, _
    granteeName As String, _
    revokeGrant As Boolean, _
    cascade As Boolean, _
    asRole As String _
)
public void Revoke (
    DatabasePermissionSet permission,
    string granteeName,
    bool revokeGrant,
    bool cascade,
    string asRole
)
public:
void Revoke (
    DatabasePermissionSet^ permission, 
    String^ granteeName, 
    bool revokeGrant, 
    bool cascade, 
    String^ asRole
)
public void Revoke (
    DatabasePermissionSet permission, 
    String granteeName, 
    boolean revokeGrant, 
    boolean cascade, 
    String asRole
)
public function Revoke (
    permission : DatabasePermissionSet, 
    granteeName : String, 
    revokeGrant : boolean, 
    cascade : boolean, 
    asRole : String
)

パラメータ

  • granteeName
    権限セットへのアクセスを取り消す権限許可対象ユーザーを示す String 値です。
  • revokeGrant
    権限許可対象ユーザーに対し、指定した権限のセットをデータベースの他のユーザーから取り消す権限を付与するかどうかを示す Boolean プロパティです。

    True の場合は、権限許可対象ユーザーに対し、指定した権限セットをデータベースの他のユーザーから取り消す権限を付与します。

    False の場合は、権限許可対象ユーザーに対し、指定した権限セットをデータベースの他のユーザーから取り消す権限を付与しません。

  • cascade
    指定した権限セットを権限許可対象ユーザーから許可されたユーザーについても、権限セットを取り消すかどうかを示す Boolean プロパティです。

    True の場合は、データベースの指定した権限セットが取り消されるのは、権限許可対象ユーザーだけでなく、このユーザーが特定の権限セットを許可した他のユーザーも対象となります。

    False の場合は、特定の権限のセットが取り消されるのは、権限許可対象ユーザーだけです。

  • asRole
    データベースの指定した権限セットを他のユーザーから取り消す場合に、取り消しの前提となるロールを示す String 値です。権限許可対象ユーザーが複数のロールに属している場合に、このパラメータを使用します。

解説

更新されたテキスト :2006 年 7 月 17 日

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

使用例

次の例は、サーバー権限で Revoke メソッドを使用する方法を示しています。このメソッドは、データベース権限の場合と同じです。

'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 のインストールに必要なハードウェアおよびソフトウェア」を参照してください。

参照

関連項目

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

その他の技術情報

Visual Basic .NET でデータベースを作成、変更、および削除する方法
権限の許可、取り消し、および拒否
データベースの作成、変更、および削除
CREATE DATABASE (Transact-SQL)

変更履歴

リリース

履歴

2006 年 7 月 17 日

変更内容 :
  • 「例」セクションにコードを追加しました。