NetworkCredential Constructeurs

Définition

Initialise une nouvelle instance de la classe NetworkCredential.

Surcharges

NetworkCredential()

Initialise une nouvelle instance de la classe NetworkCredential.

NetworkCredential(String, SecureString)

Initialise une nouvelle instance de la classe NetworkCredential avec le nom d'utilisateur et le mot de passe spécifiés.

NetworkCredential(String, String)

Initialise une nouvelle instance de la classe NetworkCredential avec le nom d'utilisateur et le mot de passe spécifiés.

NetworkCredential(String, SecureString, String)

Initialise une nouvelle instance de la classe NetworkCredential avec le nom d'utilisateur, le mot de passe et le domaine spécifiés.

NetworkCredential(String, String, String)

Initialise une nouvelle instance de la classe NetworkCredential avec le nom d'utilisateur, le mot de passe et le domaine spécifiés.

NetworkCredential()

Source:
NetworkCredential.cs
Source:
NetworkCredential.cs
Source:
NetworkCredential.cs

Initialise une nouvelle instance de la classe NetworkCredential.

public:
 NetworkCredential();
public NetworkCredential ();
Public Sub New ()

Remarques

Le constructeur sans paramètre de la NetworkCredential classe initialise toutes les propriétés en null.

S’applique à

NetworkCredential(String, SecureString)

Source:
NetworkCredential.cs
Source:
NetworkCredential.cs
Source:
NetworkCredential.cs

Important

Cette API n’est pas conforme CLS.

Initialise une nouvelle instance de la classe NetworkCredential avec le nom d'utilisateur et le mot de passe spécifiés.

public:
 NetworkCredential(System::String ^ userName, System::Security::SecureString ^ password);
[System.CLSCompliant(false)]
public NetworkCredential (string? userName, System.Security.SecureString? password);
[System.CLSCompliant(false)]
public NetworkCredential (string userName, System.Security.SecureString password);
public NetworkCredential (string userName, System.Security.SecureString password);
[<System.CLSCompliant(false)>]
new System.Net.NetworkCredential : string * System.Security.SecureString -> System.Net.NetworkCredential
new System.Net.NetworkCredential : string * System.Security.SecureString -> System.Net.NetworkCredential
Public Sub New (userName As String, password As SecureString)

Paramètres

userName
String

Nom d'utilisateur associé aux informations d'identification.

password
SecureString

Mot de passe du nom d'utilisateur associé aux informations d'identification.

Attributs

Exceptions

La classe SecureString n'est pas prise en charge sur cette plateforme.

Remarques

Le constructeur initialise un NetworkCredential objet avec la UserName propriété définie sur userName et la Password propriété définie sur password.

Le password paramètre est un SecureString instance.

Si ce constructeur est appelé avec le password paramètre défini nullsur , une nouvelle instance de SecureString est initialisée. Si les chaînes sécurisées ne sont pas prises en charge sur cette plateforme, le NotSupportedException est levée

S’applique à

NetworkCredential(String, String)

Source:
NetworkCredential.cs
Source:
NetworkCredential.cs
Source:
NetworkCredential.cs

Initialise une nouvelle instance de la classe NetworkCredential avec le nom d'utilisateur et le mot de passe spécifiés.

public:
 NetworkCredential(System::String ^ userName, System::String ^ password);
public NetworkCredential (string userName, string password);
public NetworkCredential (string? userName, string? password);
new System.Net.NetworkCredential : string * string -> System.Net.NetworkCredential
Public Sub New (userName As String, password As String)

Paramètres

userName
String

Nom d'utilisateur associé aux informations d'identification.

password
String

Mot de passe du nom d'utilisateur associé aux informations d'identification.

Exemples

L’exemple de code suivant crée un NetworkCredential objet à l’aide du nom d’utilisateur et du mot de passe spécifiés.

// Call the onstructor  to create an instance of NetworkCredential with the
// specified user name and password.
NetworkCredential^ myCredentials = gcnew NetworkCredential( username,passwd );

// Create a WebRequest with the specified URL.
WebRequest^ myWebRequest = WebRequest::Create( url );
myCredentials->Domain = domain;
myWebRequest->Credentials = myCredentials;
Console::WriteLine( "\n\nCredentials Domain : {0} , UserName : {1} , Password : {2}",
   myCredentials->Domain, myCredentials->UserName, myCredentials->Password );
Console::WriteLine( "\n\nRequest to Url is sent.Waiting for response..." );

// Send the request and wait for a response.
WebResponse^ myWebResponse = myWebRequest->GetResponse();

// Process the response.
Console::WriteLine( "\nResponse received successfully." );

// Release the resources of the response object.
myWebResponse->Close();
 // Call the constructor to create an instance of NetworkCredential with the
 // specified user name and password.
 NetworkCredential myCredentials = new NetworkCredential(username,passwd);

// Create a WebRequest with the specified URL.
WebRequest myWebRequest = WebRequest.Create(url);
myCredentials.Domain = domain;
myWebRequest.Credentials = myCredentials;
Console.WriteLine("\n\nCredentials Domain : {0} , UserName : {1} , Password : {2}",
myCredentials.Domain, myCredentials.UserName, myCredentials.Password);
Console.WriteLine("\n\nRequest to Url is sent.Waiting for response...");

// Send the request and wait for a response.
WebResponse myWebResponse = myWebRequest.GetResponse();

// Process the response.
Console.WriteLine("\nResponse received successfully.");
// Release the resources of the response object.
myWebResponse.Close();
' Call the constructor  to create an instance of NetworkCredential with the
' specified user name and password.
Dim myCredentials As New NetworkCredential(username, passwd)
' Create a WebRequest with the specified URL. 
Dim myWebRequest As WebRequest = WebRequest.Create(url)
myCredentials.Domain = domain
myWebRequest.Credentials = myCredentials
Console.WriteLine(ControlChars.Cr + ControlChars.Cr + "Credentials Domain : {0} , UserName : {1} , Password : {2}", myCredentials.Domain, myCredentials.UserName, myCredentials.Password)
Console.WriteLine(ControlChars.Cr + ControlChars.Cr + "Request to Url is sent.Waiting for response...")
' Send the request and wait for a response.
Dim myWebResponse As WebResponse = myWebRequest.GetResponse()
' Process the response.
Console.WriteLine(ControlChars.Cr + "Response received successfully.")
' Release the resources of the response object.
myWebResponse.Close()

Remarques

Le constructeur initialise un NetworkCredential objet avec la UserName propriété définie sur userName et la Password propriété définie sur password.

S’applique à

NetworkCredential(String, SecureString, String)

Source:
NetworkCredential.cs
Source:
NetworkCredential.cs
Source:
NetworkCredential.cs

Important

Cette API n’est pas conforme CLS.

Initialise une nouvelle instance de la classe NetworkCredential avec le nom d'utilisateur, le mot de passe et le domaine spécifiés.

public:
 NetworkCredential(System::String ^ userName, System::Security::SecureString ^ password, System::String ^ domain);
[System.CLSCompliant(false)]
public NetworkCredential (string? userName, System.Security.SecureString? password, string? domain);
[System.CLSCompliant(false)]
public NetworkCredential (string userName, System.Security.SecureString password, string domain);
public NetworkCredential (string userName, System.Security.SecureString password, string domain);
[<System.CLSCompliant(false)>]
new System.Net.NetworkCredential : string * System.Security.SecureString * string -> System.Net.NetworkCredential
new System.Net.NetworkCredential : string * System.Security.SecureString * string -> System.Net.NetworkCredential
Public Sub New (userName As String, password As SecureString, domain As String)

Paramètres

userName
String

Nom d'utilisateur associé aux informations d'identification.

password
SecureString

Mot de passe du nom d'utilisateur associé aux informations d'identification.

domain
String

Domaine associé à ces informations d'identification.

Attributs

Exceptions

La classe SecureString n'est pas prise en charge sur cette plateforme.

Remarques

Le constructeur initialise un NetworkCredential objet avec la UserName propriété définie sur userName, la Password propriété définie sur passwordet la Domain propriété définie sur domain.

Le password paramètre est un SecureString instance.

Si ce constructeur est appelé avec le password paramètre défini nullsur , une nouvelle instance de SecureString est initialisée. Si les chaînes sécurisées ne sont pas prises en charge sur cette plateforme, le NotSupportedException est levée

S’applique à

NetworkCredential(String, String, String)

Source:
NetworkCredential.cs
Source:
NetworkCredential.cs
Source:
NetworkCredential.cs

Initialise une nouvelle instance de la classe NetworkCredential avec le nom d'utilisateur, le mot de passe et le domaine spécifiés.

public:
 NetworkCredential(System::String ^ userName, System::String ^ password, System::String ^ domain);
public NetworkCredential (string userName, string password, string domain);
public NetworkCredential (string? userName, string? password, string? domain);
new System.Net.NetworkCredential : string * string * string -> System.Net.NetworkCredential
Public Sub New (userName As String, password As String, domain As String)

Paramètres

userName
String

Nom d'utilisateur associé aux informations d'identification.

password
String

Mot de passe du nom d'utilisateur associé aux informations d'identification.

domain
String

Domaine associé à ces informations d'identification.

Remarques

Le constructeur initialise un NetworkCredential objet avec la UserName propriété définie sur userName, la Password propriété définie sur passwordet la Domain propriété définie sur domain.

S’applique à