NetworkCredential コンストラクター
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
NetworkCredential クラスの新しいインスタンスを初期化します。
オーバーロード
| 名前 | 説明 |
|---|---|
| NetworkCredential() |
NetworkCredential クラスの新しいインスタンスを初期化します。 |
| NetworkCredential(String, SecureString) |
指定したユーザー名とパスワードを使用して、 NetworkCredential クラスの新しいインスタンスを初期化します。 |
| NetworkCredential(String, String) |
指定したユーザー名とパスワードを使用して、 NetworkCredential クラスの新しいインスタンスを初期化します。 |
| NetworkCredential(String, SecureString, String) |
指定したユーザー名、パスワード、およびドメインを使用して、 NetworkCredential クラスの新しいインスタンスを初期化します。 |
| NetworkCredential(String, String, String) |
指定したユーザー名、パスワード、およびドメインを使用して、 NetworkCredential クラスの新しいインスタンスを初期化します。 |
NetworkCredential()
NetworkCredential クラスの新しいインスタンスを初期化します。
public:
NetworkCredential();
public NetworkCredential();
Public Sub New ()
注釈
NetworkCredential クラスのパラメーターなしのコンストラクターは、nullするすべてのプロパティを初期化します。
適用対象
NetworkCredential(String, SecureString)
重要
この 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 クラスはサポートされていません。
注釈
コンストラクターは、UserName プロパティを userName に設定し、Password プロパティを password に設定して、NetworkCredential オブジェクトを初期化します。
password パラメーターは、SecureString インスタンスです。
password パラメーターを null に設定してこのコンストラクターを呼び出すと、SecureStringの新しいインスタンスが初期化されます。セキュリティで保護された文字列がこのプラットフォームでサポートされていない場合は、NotSupportedExceptionがスローされます
適用対象
NetworkCredential(String, String)
指定したユーザー名とパスワードを使用して、 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 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()
注釈
コンストラクターは、UserName プロパティを userName に設定し、Password プロパティを password に設定して、NetworkCredential オブジェクトを初期化します。
適用対象
NetworkCredential(String, SecureString, String)
重要
この 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 クラスはサポートされていません。
注釈
コンストラクターは、UserName プロパティを userName に設定し、Password プロパティを password に設定し、Domain プロパティを domain に設定して、NetworkCredential オブジェクトを初期化します。
password パラメーターは、SecureString インスタンスです。
password パラメーターを null に設定してこのコンストラクターを呼び出すと、SecureStringの新しいインスタンスが初期化されます。セキュリティで保護された文字列がこのプラットフォームでサポートされていない場合は、NotSupportedExceptionがスローされます
適用対象
NetworkCredential(String, String, String)
指定したユーザー名、パスワード、およびドメインを使用して、 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
これらの資格情報に関連付けられているドメイン。
注釈
コンストラクターは、UserName プロパティを userName に設定し、Password プロパティを password に設定し、Domain プロパティを domain に設定して、NetworkCredential オブジェクトを初期化します。