Udostępnij za pośrednictwem


Metoda Table.Grant (ObjectPermissionSet, String, Boolean)

Dotacje dostęp do określonych uprawnień i możliwości udzielenia dostępu do innych zastosowań grantee określonego w tabela.

Przestrzeń nazw:  Microsoft.SqlServer.Management.Smo
Zestaw:  Microsoft.SqlServer.Smo (w Microsoft.SqlServer.Smo.dll)

Składnia

'Deklaracja
Public Sub Grant ( _
    permission As ObjectPermissionSet, _
    granteeName As String, _
    grantGrant As Boolean _
)
'Użycie
Dim instance As Table
Dim permission As ObjectPermissionSet
Dim granteeName As String
Dim grantGrant As Boolean

instance.Grant(permission, granteeName, _
    grantGrant)
public void Grant(
    ObjectPermissionSet permission,
    string granteeName,
    bool grantGrant
)
public:
virtual void Grant(
    ObjectPermissionSet^ permission, 
    String^ granteeName, 
    bool grantGrant
) sealed
abstract Grant : 
        permission:ObjectPermissionSet * 
        granteeName:string * 
        grantGrant:bool -> unit 
override Grant : 
        permission:ObjectPermissionSet * 
        granteeName:string * 
        grantGrant:bool -> unit 
public final function Grant(
    permission : ObjectPermissionSet, 
    granteeName : String, 
    grantGrant : boolean
)

Parametry

  • granteeName
    Typ: System.String
    A String wartość określająca grantee niedozwolone określonego zestaw uprawnień.
  • grantGrant
    Typ: System.Boolean
    A Boolean właściwość, która określa, czy grantee jest możliwość udzielenia zestaw uprawnień innym użytkownikom na tabela.
    Jeśli True, grantee jest możliwość udzielenia określonego zestaw uprawnień innych użytkowników w tabela.W przeciwnym razie jest używana wartość False.

Implementacje

IObjectPermission.Grant(ObjectPermissionSet, String, Boolean)

Przykłady

Poniższy przykład kodu pokazuje jak udzielić uprawnień konta grantee na zaznaczanie elementów tabela.grantee Konto jest symbolem zastępczym dla dowolnego konta użytkownika zdefiniowane.

Następującego schemat bazy danych jest używany dla tej wstawki.

//CREATE DATABASE MYTESTDB;
//GO

//USE MYTESTDB;
//GO

//CREATE TABLE TABLE1(
//    id int,
//    name varchar(32)
//);
//GO

C#

Server srv = new Server("(local)");
Database db = srv.Databases["MYTESTDB"];

Table tb = db.Tables[0];

ObjectPermissionSet objPermissionSet = new ObjectPermissionSet(ObjectPermission.Select);
objPermissionSet.Select = true;
tb.Grant(objPermissionSet, grantee, true);

PowerShell

$srv = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")
$db = New-Object Microsoft.SqlServer.Management.Smo.Database
$db = $srv.Databases.Item("MYTESTDB")
$tb = $db.Tables[0]

$objPermissionSet = new-object Microsoft.SqlServer.Management.Smo.ObjectPermissionSet([Microsoft.SqlServer.Management.Smo.ObjectPermission]::Select)
$objPermissionSet.Select = $TRUE
$tb.Grant($objPermissionSet, grantee, $TRUE)