共用方式為


Server.ProxyAccount 屬性

Gets the proxy account 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 ProxyAccount As ServerProxyAccount 
    Get
'用途
Dim instance As Server 
Dim value As ServerProxyAccount 

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

屬性值

型別:Microsoft.SqlServer.Management.Smo.ServerProxyAccount
A ServerProxyAccount object that specifies the proxy account associated with the instance of SQL Server.

備註

The proxy account defines a security context in which a SQL Server Agent job step can run. The ProxyAccount property points to the ServerProxyAccount object. This object specifies the proxy account that is used by the instance of SQL Server Agent.

範例

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
$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 命名空間

其他資源

設定屬性

管理伺服器