다음을 통해 공유


AuthenticationManager.CustomTargetNameDictionary 속성

정의

Kerberos 인증 중에 사용한 요청 WebRequest 및 파생 클래스에 대한 호스트를 식별하는 데 사용되는 SPN(서비스 사용자 이름)이 포함된 사전을 가져옵니다.

public:
 static property System::Collections::Specialized::StringDictionary ^ CustomTargetNameDictionary { System::Collections::Specialized::StringDictionary ^ get(); };
public static System.Collections.Specialized.StringDictionary CustomTargetNameDictionary { get; }
static member CustomTargetNameDictionary : System.Collections.Specialized.StringDictionary
Public Shared ReadOnly Property CustomTargetNameDictionary As StringDictionary

속성 값

호스트 정보로 구성된 키에 대한 SPN 값을 포함하는 쓰기 가능 StringDictionary 파일입니다.

예제

다음 코드 예제에서는 의 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>

*/

설명

SPN은 클라이언트가 상호 인증을 위해 서버에서 서비스 또는 애플리케이션의 인스턴스를 고유하게 식별하는 이름입니다. 상호 인증은 기본적으로 요청되며 요청에 설정 WebRequest.AuthenticationLevelMutualAuthRequired 하여 요구할 수 있습니다.

상호 인증이 WebRequest 필요한 경우 대상에 대한 SPN을 클라이언트에서 제공해야 합니다. SPN을 알고 있는 경우 요청을 보내기 전에 SPN을 CustomTargetNameDictionary 추가할 수 있습니다. 이 사전에 AuthenticationManager SPN 정보를 추가하지 않은 경우 이 메서드를 사용하여 RequestUri 가장 가능성이 큰 SPN을 작성합니다. 그러나 계산된 값이며 올바르지 않을 수 있습니다. 상호 인증이 시도되고 실패하는 경우 사전을 확인하여 계산된 SPN을 확인할 수 있습니다. 인증 프로토콜이 상호 인증을 지원하지 않는 경우 사전에 SPN이 입력되지 않습니다.

이 사전에 SPN 값을 추가하려면 해당 값을 키로 사용합니다 AbsoluteUriRequestUri . 내부적으로 키는 기본 포트가 아닌 경우 , Host키를 Port 포함Scheme하도록 잘립니다.

메모

메서드 및 속성에 CustomTargetNameDictionary 액세스하려면 제한 WebPermission되지 않습니다.

메모

프록시를 통해 Kerberos 인증을 수행하는 경우 프록시와 최종 호스트 이름을 SPN으로 확인해야 합니다. 프록시 이름 확인은 시간 제한으로 보호됩니다. SPN에 대한 최종 호스트 이름을 확인하려면 DNS 조회가 필요하며 이 작업과 직접 연결된 시간 제한이 없습니다. 따라서 동기 작업은 시간 제한에 더 오래 걸릴 수 있습니다. 이를 해결하려면 요청하기 전에 SPN 캐시에 최종 호스트의 URI 접두사를 추가합니다.

버전 3.5 SP1은 이제 속성이 설정되지 않은 경우 CustomTargetNameDictionary NTLM(NT LAN Manager) 인증 교환에서 SPN의 요청 URL에 사용되는 호스트 이름을 기본적으로 지정합니다. 요청 URL에 사용되는 호스트 이름은 클라이언트 요청에 지정된 System.Net.HttpRequestHeader 호스트 헤더와 다를 수 있습니다. 요청 URL에 사용되는 호스트 이름은 서버의 실제 호스트 이름, 서버의 컴퓨터 이름, 컴퓨터의 IP 주소 또는 루프백 주소와 다를 수 있습니다. 이러한 경우 Windows는 인증 요청에 실패합니다. 이 문제를 해결하려면 클라이언트 요청의 요청 URL에 사용되는 호스트 이름(예: "contoso")이 실제로 로컬 컴퓨터의 대체 이름임을 Windows에 알려야 할 수 있습니다.

적용 대상

추가 정보