NetworkCredential クラス
アセンブリ: System (system.dll 内)


NetworkCredential クラスは、基本認証、ダイジェスト認証、NTLM 認証、Kerberos 認証などのパスワードに基づく認証方式に資格情報を提供する基本クラスです。CredentialCache クラスなどの ICredentials インターフェイスを実装するクラスは、NetworkCredential オブジェクトを返します。
このクラスは、SSL (Secure Sockets Layer) クライアント認証などの公開キーに基づく認証方式はサポートしていません。

NetworkCredential オブジェクトを CredentialCache の一連の URI (Uniform Resource Identifier) に関連付けるコード例を次に示します。この例では、次に、CredentialCache を WebRequest オブジェクトに渡し、これを使用してインターネット サーバーへの要求を認証します。
Dim myCred As New NetworkCredential(SecurelyStoredUserName,SecurelyStoredPassword,SecurelyStoredDomain ) Dim myCache As New CredentialCache() myCache.Add(New Uri("www.contoso.com"), "Basic", myCred) myCache.Add(New Uri("app.contoso.com"), "Basic", myCred) Dim wr As WebRequest = WebRequest.Create("www.contoso.com") wr.Credentials = myCache
NetworkCredential myCred = new NetworkCredential( SecurelyStoredUserName,SecurelyStoredPassword,SecurelyStoredDomain); CredentialCache myCache = new CredentialCache(); myCache.Add(new Uri("www.contoso.com"), "Basic", myCred); myCache.Add(new Uri("app.contoso.com"), "Basic", myCred); WebRequest wr = WebRequest.Create("www.contoso.com"); wr.Credentials = myCache;
NetworkCredential^ myCred = gcnew NetworkCredential( SecurelyStoredUserName,SecurelyStoredPassword,SecurelyStoredDomain ); CredentialCache^ myCache = gcnew CredentialCache; myCache->Add( gcnew Uri( "www.contoso.com" ), "Basic", myCred ); myCache->Add( gcnew Uri( "app.contoso.com" ), "Basic", myCred ); WebRequest^ wr = WebRequest::Create( "www.contoso.com" ); wr->Credentials = myCache;
NetworkCredential myCred =new NetworkCredential(securelyStoredUserName , securelyStoredPassword,securelyStoredDomain); CredentialCache myCache = new CredentialCache(); myCache.Add(new Uri("www.contoso.com"), "Basic", myCred); myCache.Add(new Uri("app.contoso.com"), "Basic", myCred); WebRequest wr = WebRequest.Create("www.contoso.com"); wr.set_Credentials(myCache);
var myCred : NetworkCredential = new NetworkCredential( SecurelyStoredUserName, SecurelyStoredPassword, SecurelyStoredDomain ) var myCache : CredentialCache = new CredentialCache() myCache.Add(new Uri("www.contoso.com"), "Basic", myCred) myCache.Add(new Uri("app.contoso.com"), "Basic", myCred) var wr : WebRequest = WebRequest.Create("www.contoso.com") wr.Credentials = myCache

System.Net.NetworkCredential


Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


NetworkCredential コンストラクタ ()
アセンブリ: System (system.dll 内)



Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


NetworkCredential コンストラクタ (String, String)
アセンブリ: System (system.dll 内)

Dim userName As String Dim password As String Dim instance As New NetworkCredential(userName, password)

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

指定したユーザー名とパスワードを使用して、NetworkCredential オブジェクトを作成するコード例を次に示します。
' 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()
// Call the onstructor 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 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 onstructor 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.set_Domain(domain); myWebRequest.set_Credentials(myCredentials); Console.WriteLine("\n\nCredentials Domain : {0} , UserName : " + "{1} , Password : {2}", myCredentials.get_Domain(), myCredentials.get_UserName(), myCredentials.get_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();

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


NetworkCredential コンストラクタ (String, String, String)
アセンブリ: System (system.dll 内)

Dim userName As String Dim password As String Dim domain As String Dim instance As New NetworkCredential(userName, password, domain)

コンストラクタは UserName プロパティを userName に、Password プロパティを password に、および Domain プロパティを domain に設定して、NetworkCredential オブジェクトを初期化します。

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


NetworkCredential コンストラクタ

名前 | 説明 |
---|---|
NetworkCredential () | NetworkCredential クラスの新しいインスタンスを初期化します。 .NET Compact Framework によってサポートされています。 |
NetworkCredential (String, String) | 指定したユーザー名とパスワードを使用して、NetworkCredential クラスの新しいインスタンスを初期化します。 .NET Compact Framework によってサポートされています。 |
NetworkCredential (String, String, String) | 指定したユーザー名、パスワード、およびドメインを使用して、NetworkCredential クラスの新しいインスタンスを初期化します。 .NET Compact Framework によってサポートされています。 |

NetworkCredential プロパティ
NetworkCredential メソッド

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
![]() | GetCredential | オーバーロードされます。 指定した認証の種類用に NetworkCredential クラスのインスタンスを返します。 |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

NetworkCredential メンバ
基本認証、ダイジェスト認証、NTLM 認証、Kerberos 認証などのパスワードに基づく認証方式に資格情報を提供します。
NetworkCredential データ型で公開されるメンバを以下の表に示します。



名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
![]() | GetCredential | オーバーロードされます。 指定した認証の種類用に NetworkCredential クラスのインスタンスを返します。 |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

Weblioに収録されているすべての辞書からNetworkCredentialを検索する場合は、下記のリンクをクリックしてください。

- NetworkCredentialのページへのリンク