NetworkCredential Konstruktory

Definicja

Inicjuje nowe wystąpienie klasy NetworkCredential.

Przeciążenia

NetworkCredential()

Inicjuje nowe wystąpienie klasy NetworkCredential.

NetworkCredential(String, SecureString)

Inicjuje NetworkCredential nowe wystąpienie klasy z określoną nazwą użytkownika i hasłem.

NetworkCredential(String, String)

Inicjuje NetworkCredential nowe wystąpienie klasy z określoną nazwą użytkownika i hasłem.

NetworkCredential(String, SecureString, String)

Inicjuje NetworkCredential nowe wystąpienie klasy z określoną nazwą użytkownika, hasłem i domeną.

NetworkCredential(String, String, String)

Inicjuje NetworkCredential nowe wystąpienie klasy z określoną nazwą użytkownika, hasłem i domeną.

NetworkCredential()

Źródło:
NetworkCredential.cs
Źródło:
NetworkCredential.cs
Źródło:
NetworkCredential.cs

Inicjuje nowe wystąpienie klasy NetworkCredential.

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

Uwagi

Konstruktor bez parametrów klasy inicjuje NetworkCredential wszystkie właściwości do null.

Dotyczy

NetworkCredential(String, SecureString)

Źródło:
NetworkCredential.cs
Źródło:
NetworkCredential.cs
Źródło:
NetworkCredential.cs

Ważne

Ten interfejs API nie jest zgodny ze specyfikacją CLS.

Inicjuje NetworkCredential nowe wystąpienie klasy z określoną nazwą użytkownika i hasłem.

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)

Parametry

userName
String

Nazwa użytkownika skojarzona z poświadczeniami.

password
SecureString

Hasło nazwy użytkownika skojarzonej z poświadczeniami.

Atrybuty

Wyjątki

Klasa nie jest obsługiwana SecureString na tej platformie.

Uwagi

Konstruktor inicjuje NetworkCredential obiekt z właściwością ustawioną UserName na userName i właściwość ustawioną Password na password.

Parametr password jest wystąpieniem SecureString .

Jeśli ten konstruktor jest wywoływany z parametrem ustawionym na passwordnull, nowe wystąpienie SecureString jest inicjowane, Jeśli bezpieczne ciągi nie są obsługiwane na tej platformie, NotSupportedException zostanie zgłoszony

Dotyczy

NetworkCredential(String, String)

Źródło:
NetworkCredential.cs
Źródło:
NetworkCredential.cs
Źródło:
NetworkCredential.cs

Inicjuje NetworkCredential nowe wystąpienie klasy z określoną nazwą użytkownika i hasłem.

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)

Parametry

userName
String

Nazwa użytkownika skojarzona z poświadczeniami.

password
String

Hasło nazwy użytkownika skojarzonej z poświadczeniami.

Przykłady

Poniższy przykład kodu tworzy NetworkCredential obiekt przy użyciu określonej nazwy użytkownika i hasła.

// 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()

Uwagi

Konstruktor inicjuje NetworkCredential obiekt z właściwością ustawioną UserName na userName i właściwość ustawioną Password na password.

Dotyczy

NetworkCredential(String, SecureString, String)

Źródło:
NetworkCredential.cs
Źródło:
NetworkCredential.cs
Źródło:
NetworkCredential.cs

Ważne

Ten interfejs API nie jest zgodny ze specyfikacją CLS.

Inicjuje NetworkCredential nowe wystąpienie klasy z określoną nazwą użytkownika, hasłem i domeną.

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)

Parametry

userName
String

Nazwa użytkownika skojarzona z poświadczeniami.

password
SecureString

Hasło nazwy użytkownika skojarzonej z poświadczeniami.

domain
String

Domena skojarzona z tymi poświadczeniami.

Atrybuty

Wyjątki

Klasa nie jest obsługiwana SecureString na tej platformie.

Uwagi

Konstruktor inicjuje NetworkCredential obiekt z właściwością ustawioną UserName na userName, Password właściwość ustawioną na , a właściwość ustawioną Domain na domainpassword.

Parametr password jest wystąpieniem SecureString .

Jeśli ten konstruktor jest wywoływany z parametrem ustawionym na passwordnull, nowe wystąpienie SecureString jest inicjowane, Jeśli bezpieczne ciągi nie są obsługiwane na tej platformie, NotSupportedException zostanie zgłoszony

Dotyczy

NetworkCredential(String, String, String)

Źródło:
NetworkCredential.cs
Źródło:
NetworkCredential.cs
Źródło:
NetworkCredential.cs

Inicjuje NetworkCredential nowe wystąpienie klasy z określoną nazwą użytkownika, hasłem i domeną.

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)

Parametry

userName
String

Nazwa użytkownika skojarzona z poświadczeniami.

password
String

Hasło nazwy użytkownika skojarzonej z poświadczeniami.

domain
String

Domena skojarzona z tymi poświadczeniami.

Uwagi

Konstruktor inicjuje NetworkCredential obiekt z właściwością ustawioną UserName na userName, Password właściwość ustawioną na , a właściwość ustawioną Domain na domainpassword.

Dotyczy