AuthenticationManager.CustomTargetNameDictionary プロパティ
アセンブリ: System (system.dll 内)

ホスト情報で構成されているキーの SPN 値を格納している書き込み可能な StringDictionary。

SPN は、相互認証のために、クライアントがサービスのインスタンスやサーバー上のアプリケーションを一意に識別するために使用する名前です。相互認証は、既定で要求されます。また、WebRequest.AuthenticationLevel を MutualAuthRequired に設定することにより、要求がこの認証を必要とするように指定することもできます。
WebRequest が相互認証を必要とする場合、送信先の SPN はクライアント側で指定する必要があります。SPN が判明している場合は、要求の送信前に CustomTargetNameDictionary に追加できます。このディクショナリに SPN 情報が追加されていない場合、AuthenticationManager は RequestUri メソッドを使用して最も可能性が高い SPN を構成しますが、これは算出された値であり、正しくない可能性があります。相互認証が試行され、失敗した場合は、ディクショナリをチェックして、算出された SPN を確認できます。認証プロトコルが相互認証をサポートしていない場合、SPN はディクショナリに入力されません。
このディクショナリに SPN 値を追加するには、キーとして RequestUri の AbsoluteUri を使用します。キーは、内部的に、Scheme、Host、および Port (これが既定のポートではない場合) を含むように切り詰められます。
![]() |
---|
CustomTargetNameDictionary のメソッドおよびプロパティにアクセスするには、無制限の WebPermission が必要です。 |

CustomTargetNameDictionary の内容を表示するコード例を次に示します。
public static void RequestResource(Uri resource) { // Set policy to send credentials when using HTTPS and basic authentication. // Create a new HttpWebRequest object for the specified resource. WebRequest request=(WebRequest) WebRequest.Create(resource); // Supply client credentials for basic authentication. request.UseDefaultCredentials = true; request.AuthenticationLevel = AuthenticationLevel.MutualAuthRequired; HttpWebResponse response = (HttpWebResponse) request.GetResponse(); // Determine mutual authentication was used. Console.WriteLine("Is mutually authenticated? {0}", response.IsMutuallyAuthenticated); System.Collections.Specialized.StringDictionary spnDictionary = AuthenticationManager.CustomTargetNameDictionary; foreach (System.Collections.DictionaryEntry e in spnDictionary) { Console.WriteLine("Key: {0} - {1}", e.Key as string, e.Value as string); } // Read and display the response. System.IO.Stream streamResponse = response.GetResponseStream(); System.IO.StreamReader streamRead = new System.IO.StreamReader(streamResponse); string responseString = streamRead.ReadToEnd(); Console.WriteLine(responseString); // Close the stream objects. streamResponse.Close(); streamRead.Close(); // Release the HttpWebResponse. response.Close(); } /* The output from this example will differ based on the requested resource and whether mutual authentication was successful. For the purpose of illustration , a sample of the output is shown here: Is mutually authenticated? True Key: http://server1.someDomain.contoso.com - HTTP/server1.someDomain.contoso.com <html> ... </html> */
static void RequestResource( Uri^ resource ) { // Set policy to send credentials when using HTTPS and basic authentication. // Create a new HttpWebRequest object for the specified resource. WebRequest^ request = dynamic_cast<WebRequest^>(WebRequest::Create( resource )); // Supply client credentials for basic authentication. request->UseDefaultCredentials = true; request->AuthenticationLevel = AuthenticationLevel::MutualAuthRequired; HttpWebResponse^ response = dynamic_cast<HttpWebResponse^>(request->GetResponse()); // Determine mutual authentication was used. Console::WriteLine( L"Is mutually authenticated? {0}", response->IsMutuallyAuthenticated ); System::Collections::Specialized::StringDictionary^ spnDictionary = AuthenticationManager::CustomTargetNameDictionary; System::Collections::IEnumerator^ myEnum = spnDictionary->GetEnumerator(); while ( myEnum->MoveNext() ) { DictionaryEntry^ e = safe_cast<DictionaryEntry^>(myEnum->Current); Console::WriteLine( "Key: {0} - {1}", dynamic_cast<String^>(e->Key), dynamic_cast<String^>(e->Value) ); } // Read and display the response. System::IO::Stream^ streamResponse = response->GetResponseStream(); System::IO::StreamReader^ streamRead = gcnew System::IO::StreamReader( streamResponse ); String^ responseString = streamRead->ReadToEnd(); Console::WriteLine( responseString ); // Close the stream objects. streamResponse->Close(); streamRead->Close(); // Release the HttpWebResponse. response->Close(); } /* The output from this example will differ based on the requested resource and whether mutual authentication was successful. For the purpose of illustration , a sample of the output is shown here: Is mutually authenticated? True Key: http://server1.someDomain.contoso.com - HTTP/server1.someDomain.contoso.com <html> ... </html> */

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からAuthenticationManager.CustomTargetNameDictionary プロパティを検索する場合は、下記のリンクをクリックしてください。

- AuthenticationManager.CustomTargetNameDictionary プロパティのページへのリンク