次の方法で共有


Server.Credentials プロパティ

Credential オブジェクトのコレクションを表します。 各 Credential オブジェクトは、SQL Server のインスタンスで定義された資格情報を表します。

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

構文

'宣言
<SfcObjectAttribute(SfcContainerRelationship.ObjectContainer, SfcContainerCardinality.ZeroToAny,  _
    GetType(Credential))> _
Public ReadOnly Property Credentials As CredentialCollection 
    Get
'使用
Dim instance As Server 
Dim value As CredentialCollection 

value = instance.Credentials
[SfcObjectAttribute(SfcContainerRelationship.ObjectContainer, SfcContainerCardinality.ZeroToAny, 
    typeof(Credential))]
public CredentialCollection Credentials { get; }
[SfcObjectAttribute(SfcContainerRelationship::ObjectContainer, SfcContainerCardinality::ZeroToAny, 
    typeof(Credential))]
public:
property CredentialCollection^ Credentials {
    CredentialCollection^ get ();
}
[<SfcObjectAttribute(SfcContainerRelationship.ObjectContainer, SfcContainerCardinality.ZeroToAny, 
    typeof(Credential))>]
member Credentials : CredentialCollection
function get Credentials () : CredentialCollection

プロパティ値

型: Microsoft.SqlServer.Management.Smo.CredentialCollection
SQL Server のインスタンスで定義されたすべての資格情報を表す CredentialCollection オブジェクトです。

説明

資格情報は、アカウント名とパスワードを保存して、外部リソースへの権限を取得するために使用されます。 たとえば、SQL Server エージェント プロキシ アカウントは資格情報を使用して、さまざまなサブシステムへのアクセスに必要なアカウントおよびパスワード情報を保存します。これは、SQL Server エージェント ジョブの一部として使用される場合もあります。

使用例

Visual Basic

'Connect to the local, default instance of SQL Server.
Dim srv As Server
srv = New Server
'Declare a JobServer object variable and reference the SQL Agent.
Dim js As JobServer
js = srv.JobServer
'Define a Credential object variable by supplying the parent server and name arguments in the constructor.
Dim c As Credential
c = New Credential(srv, "Proxy_accnt")
'Set the identity to a valid login represented by the vIdentity string variable. 
'The sub system will run under this login.
c.Identity = vIdentity
'Create the credential on the instance of SQL Server.
c.Create()
'Define a ProxyAccount object variable by supplying the SQL Agent, the name, the credential, the description arguments in the constructor.
Dim pa As ProxyAccount
pa = New ProxyAccount(js, "Test_proxy", "Proxy_accnt", True, "Proxy account for users to run job steps in command shell.")
'Create the proxy account on the SQL Agent.
pa.Create()
'Add the login, represented by the vLogin string variable, to the proxy account. 
pa.AddLogin(vLogin)
'Add the CmdExec subsytem to the proxy account. 
pa.AddSubSystem(AgentSubSystem.CmdExec)
'Now users logged on as vLogin can run CmdExec job steps with the specified credentials.

PowerShell

$srv = new-object Microsoft.SqlServer.Management.Smo.Server("(local)")
$js = $srv.JobServer
$c = new-object Microsoft.SqlServer.Management.Smo.Credential($srv, "Proxy Accnt")
$c.Identity = vIdentity
$c.Create()
$pa = new-object Microsoft.SqlServer.Management.Smo.Agent.ProxyAccount($js, "Test proxy", "Proxy Accnt", $TRUE, "Proxy account for users to run job steps in command shell.")
$pa.Create()
$pa.AddLogin(vLogin)
$pa.AddSubSystem([Microsoft.SqlServer.Management.Smo.Agent.AgentSubSystem]::CmdExec)

関連項目

参照

Server クラス

Microsoft.SqlServer.Management.Smo 名前空間

その他の技術情報

コレクションの使用

サーバーの管理