共用方式為


Server.ServiceMasterKey 屬性

Gets the service master key associated with the instance of SQL Server.

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

語法

'宣告
<SfcObjectAttribute(SfcObjectRelationship.Object, SfcObjectCardinality.One)> _
Public ReadOnly Property ServiceMasterKey As ServiceMasterKey 
    Get
'用途
Dim instance As Server 
Dim value As ServiceMasterKey 

value = instance.ServiceMasterKey
[SfcObjectAttribute(SfcObjectRelationship.Object, SfcObjectCardinality.One)]
public ServiceMasterKey ServiceMasterKey { get; }
[SfcObjectAttribute(SfcObjectRelationship::Object, SfcObjectCardinality::One)]
public:
property ServiceMasterKey^ ServiceMasterKey {
    ServiceMasterKey^ get ();
}
[<SfcObjectAttribute(SfcObjectRelationship.Object, SfcObjectCardinality.One)>]
member ServiceMasterKey : ServiceMasterKey
function get ServiceMasterKey () : ServiceMasterKey

屬性值

型別:Microsoft.SqlServer.Management.Smo.ServiceMasterKey
A ServiceMasterKey object that specifies the service master key associated with the instance of SQL Server.

備註

The ServiceMasterKey property points to the ServiceMasterKey class. This represents the service master key, which is the top layer in the encryption hierarchy. The service master key is used to encrypt all the lower layers of the encryption hierarchy, such as database master keys, certificates, and asymmetric and symmetric keys.

The service master key is automatically generated the first time encryption is required on the instance of SQL Server. The service master key is generated by Windows and secured by the Windows data protection API. It can be decrypted only by the Windows service account under which it was created, or by a user who knows both the service account name and its password. Therefore, if you change the Windows account under which the SQL Server service runs, you must also enable decryption of the service master key by the new account.

範例

Visual Basic

'Connect to the local, default instance of SQL Server.
Dim srv As Server
srv = New Server
'Reference the service master key.
Dim smskey As ServiceMasterKey
smskey = srv.ServiceMasterKey
'Regenerate the encryption on the service master key.
smskey.Regenerate()

PowerShell

$srv = new-object Microsoft.SqlServer.Management.Smo.Server("(local)")
$smskey = $srv.ServiceMasterKey
$smskey.Regenerate()

請參閱

參考

Server 類別

Microsoft.SqlServer.Management.Smo 命名空間

其他資源

使用加密

管理伺服器