次の方法で共有


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

パラメーターを に設定してnullこのコンストラクターをpassword呼び出すと、 の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 に設定され、 プロパティが UserName に設定され、 プロパティが PassworduserNamepassword設定されたオブジェクトを___domainDomain初期化します。

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

パラメーターを に設定してnullこのコンストラクターをpassword呼び出すと、 の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 に設定され、 プロパティが UserName に設定され、 プロパティが PassworduserNamepassword設定されたオブジェクトを___domainDomain初期化します。

適用対象