NetworkCredential コンストラクター

定義

NetworkCredential クラスの新しいインスタンスを初期化します。

オーバーロード

NetworkCredential()

NetworkCredential クラスの新しいインスタンスを初期化します。

NetworkCredential(String, SecureString)

指定したユーザー名とパスワードを使用して、NetworkCredential クラスの新しいインスタンスを初期化します。

NetworkCredential(String, String)

指定したユーザー名とパスワードを使用して、NetworkCredential クラスの新しいインスタンスを初期化します。

NetworkCredential(String, SecureString, String)

指定したユーザー名、パスワード、ドメインを使用して、NetworkCredential クラスの新しいインスタンスを初期化します。

NetworkCredential(String, String, String)

指定したユーザー名、パスワード、ドメインを使用して、NetworkCredential クラスの新しいインスタンスを初期化します。

NetworkCredential()

ソース:
NetworkCredential.cs
ソース:
NetworkCredential.cs
ソース:
NetworkCredential.cs

NetworkCredential クラスの新しいインスタンスを初期化します。

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

注釈

クラスのパラメーターなしのコンストラクターは、 NetworkCredential すべてのプロパティを に null初期化します。

適用対象

NetworkCredential(String, SecureString)

ソース:
NetworkCredential.cs
ソース:
NetworkCredential.cs
ソース:
NetworkCredential.cs

重要

この API は CLS 準拠ではありません。

指定したユーザー名とパスワードを使用して、NetworkCredential クラスの新しいインスタンスを初期化します。

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)

パラメーター

userName
String

資格情報に関連付けられているユーザー名。

password
SecureString

資格情報に関連付けられているユーザー名に対応するパスワード。

属性

例外

SecureString クラスは、このプラットフォームではサポートされていません。

注釈

コンストラクターは、 プロパティを にNetworkCredential設定し、 プロパティを UserNameuserName設定して オブジェクトをpasswordPassword初期化します。

パラメーターは password インスタンスです SecureString

パラメーターを password に設定して nullこのコンストラクターを呼び出すと、 の SecureString 新しいインスタンスが初期化されます。セキュリティで保護された文字列がこのプラットフォームでサポートされていない場合は、 NotSupportedException がスローされます。

適用対象

NetworkCredential(String, String)

ソース:
NetworkCredential.cs
ソース:
NetworkCredential.cs
ソース:
NetworkCredential.cs

指定したユーザー名とパスワードを使用して、NetworkCredential クラスの新しいインスタンスを初期化します。

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)

パラメーター

userName
String

資格情報に関連付けられているユーザー名。

password
String

資格情報に関連付けられているユーザー名に対応するパスワード。

次のコード例では、 NetworkCredential 指定したユーザー名とパスワードを使用して オブジェクトを作成します。

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

注釈

コンストラクターは、 プロパティを にNetworkCredential設定し、 プロパティを UserNameuserName設定して オブジェクトをpasswordPassword初期化します。

適用対象

NetworkCredential(String, SecureString, String)

ソース:
NetworkCredential.cs
ソース:
NetworkCredential.cs
ソース:
NetworkCredential.cs

重要

この API は CLS 準拠ではありません。

指定したユーザー名、パスワード、ドメインを使用して、NetworkCredential クラスの新しいインスタンスを初期化します。

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)

パラメーター

userName
String

資格情報に関連付けられているユーザー名。

password
SecureString

資格情報に関連付けられているユーザー名に対応するパスワード。

domain
String

これらの資格情報に関連付けられているドメイン。

属性

例外

SecureString クラスは、このプラットフォームではサポートされていません。

注釈

コンストラクターは、 プロパティを NetworkCredential に設定し、 プロパティを UserNameuserNamePassword設定し、 プロパティを にpassword設定して オブジェクトをdomainDomain初期化します。

パラメーターは password インスタンスです SecureString

パラメーターを password に設定して nullこのコンストラクターを呼び出すと、 の SecureString 新しいインスタンスが初期化されます。セキュリティで保護された文字列がこのプラットフォームでサポートされていない場合は、 NotSupportedException がスローされます。

適用対象

NetworkCredential(String, String, String)

ソース:
NetworkCredential.cs
ソース:
NetworkCredential.cs
ソース:
NetworkCredential.cs

指定したユーザー名、パスワード、ドメインを使用して、NetworkCredential クラスの新しいインスタンスを初期化します。

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)

パラメーター

userName
String

資格情報に関連付けられているユーザー名。

password
String

資格情報に関連付けられているユーザー名に対応するパスワード。

domain
String

これらの資格情報に関連付けられているドメイン。

注釈

コンストラクターは、 プロパティを NetworkCredential に設定し、 プロパティを UserNameuserNamePassword設定し、 プロパティを にpassword設定して オブジェクトをdomainDomain初期化します。

適用対象