Any suggestions? Export (0) Print
Expand All

NetworkCredential Class

 

Provides credentials for password-based authentication schemes such as basic, digest, NTLM, and Kerberos authentication.

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

System.Object
  System.Net.NetworkCredential

public class NetworkCredential : ICredentials, ICredentialsByHost

NameDescription
System_CAPS_pubmethodNetworkCredential()

Initializes a new instance of the NetworkCredential class.

System_CAPS_pubmethodNetworkCredential(String, SecureString)

Initializes a new instance of the NetworkCredential class with the specified user name and password.

System_CAPS_pubmethodNetworkCredential(String, SecureString, String)

Initializes a new instance of the NetworkCredential class with the specified user name, password, and domain.

System_CAPS_pubmethodNetworkCredential(String, String)

Initializes a new instance of the NetworkCredential class with the specified user name and password.

System_CAPS_pubmethodNetworkCredential(String, String, String)

Initializes a new instance of the NetworkCredential class with the specified user name, password, and domain.

NameDescription
System_CAPS_pubpropertyDomain

Gets or sets the domain or computer name that verifies the credentials.

System_CAPS_pubpropertyPassword

Gets or sets the password for the user name associated with the credentials.

System_CAPS_pubpropertySecurePassword

Gets or sets the password as a SecureString instance.

System_CAPS_pubpropertyUserName

Gets or sets the user name associated with the credentials.

NameDescription
System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetCredential(String, Int32, String)

Returns an instance of the NetworkCredential class for the specified host, port, and authentication type.

System_CAPS_pubmethodGetCredential(Uri, String)

Returns an instance of the NetworkCredential class for the specified Uniform Resource Identifier (URI) and authentication type.

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

The NetworkCredential class is a base class that supplies credentials in password-based authentication schemes such as basic, digest, NTLM, and Kerberos. Classes that implement the ICredentials interface, such as the CredentialCache class, return NetworkCredential objects.

This class does not support public key-based authentication methods such as Secure Sockets Layer (SSL) client authentication.

The following code example associates a NetworkCredential object with a set of Uniform Resource Identifiers (URIs) in a CredentialCache. It then passes the CredentialCache to a WebRequest object, which uses it to authenticate requests to an Internet server.

NetworkCredential myCred = new NetworkCredential(
	SecurelyStoredUserName,SecurelyStoredPassword,SecurelyStoredDomain);

CredentialCache myCache = new CredentialCache();

myCache.Add(new Uri("www.contoso.com"), "Basic", myCred);
myCache.Add(new Uri("app.contoso.com"), "Basic", myCred);

WebRequest wr = WebRequest.Create("www.contoso.com");
wr.Credentials = myCache;

Universal Windows Platform
Available since 4.5
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 3.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft