Server.Credentials Property

Represents a collection of Credential objects. Each Credential object represents a credential defined on the instance of SQL Server.

Namespace:  Microsoft.SqlServer.Management.Smo
Assembly:  Microsoft.SqlServer.Smo (in Microsoft.SqlServer.Smo.dll)


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

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

Property Value

Type: Microsoft.SqlServer.Management.Smo.CredentialCollection
A CredentialCollection object that represents all the credentials defined on the instance of SQL Server.


A credential is used to store an account name and a password to gain permission to external resources. For example, SQL Server Agent proxy accounts use credentials to store the account and password information that is required to gain access to different subsystems that might be used as part of a SQL Server Agent job.


'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.
'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.
'Add the login, represented by the vLogin string variable, to the proxy account. 
'Add the CmdExec subsytem to the proxy account. 
'Now users logged on as vLogin can run CmdExec job steps with the specified credentials.