Export (0) Print
Expand All

CredentialCache.Add Method (String, Int32, String, NetworkCredential)

Adds a NetworkCredential instance for use with SMTP to the credential cache and associates it with a host computer, port, and authentication protocol.

Namespace: System.Net
Assembly: System (in system.dll)

public void Add (
	string host,
	int port,
	string authenticationType,
	NetworkCredential credential
)
public void Add (
	String host, 
	int port, 
	String authenticationType, 
	NetworkCredential credential
)
public function Add (
	host : String, 
	port : int, 
	authenticationType : String, 
	credential : NetworkCredential
)
Not applicable.

Parameters

host

A String that identifies the host computer.

port

A Int32 that specifies the port to connect to on host.

authenticationType

A String that identifies the authentication scheme used when connecting to host using cred. See Remarks.

credential

The NetworkCredential to add to the credential cache.

Exception typeCondition

ArgumentNullException

host is a null reference (Nothing in Visual Basic).

-or-

authType is a null reference (Nothing in Visual Basic).

ArgumentException

authType not an accepted value. See Remarks.

ArgumentOutOfRangeException

port is less than zero.

This method places a NetworkCredential instance for use with SMTP into the CredentialCache. The cache stores credentials in the order in which they are added to it. When the GetCredential(String,Int32,String) method is called, it returns a NetworkCredential instance that is selected by matching the host, port, and authType. The comparison is done case-insensitively.

The supported values for authType are "NTLM", "Digest", "Kerberos", and "Negotiate".

Credentials added with this method are only valid for use with SMTP. This method does not work for HTTP or FTP protocols.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show:
© 2015 Microsoft