Share via


EndpointIdentity.CreateSpnIdentity(String) 메서드

정의

지정된 이름으로 SPN(서버 사용자 이름) ID를 만듭니다.

public:
 static System::ServiceModel::EndpointIdentity ^ CreateSpnIdentity(System::String ^ spnName);
public static System.ServiceModel.EndpointIdentity CreateSpnIdentity (string spnName);
static member CreateSpnIdentity : string -> System.ServiceModel.EndpointIdentity
Public Shared Function CreateSpnIdentity (spnName As String) As EndpointIdentity

매개 변수

spnName
String

SPN ID의 이름입니다.

반환

EndpointIdentity

지정된 EndpointIdentity과 연결된 SPN spnName입니다.

예외

spnName이(가) null인 경우

예제

다음 코드에서는 이 메서드를 호출하는 방법을 보여 줍니다.

// Create the service host.
ServiceHost myServiceHost = new ServiceHost(typeof(Calculator));

// Create the binding.
WSHttpBinding binding = new WSHttpBinding();
binding.Security.Mode = SecurityMode.Message;
binding.Security.Message.ClientCredentialType =
     MessageCredentialType.Windows;

// Disable credential negotiation and establishment of the
// security context.
binding.Security.Message.NegotiateServiceCredential = false;
binding.Security.Message.EstablishSecurityContext = false;

// Create a URI for the endpoint address.
Uri httpUri = new Uri("http://localhost/Calculator");

// Create the EndpointAddress with the SPN for the Identity.
EndpointAddress ea = new EndpointAddress(httpUri,
    EndpointIdentity.CreateSpnIdentity("service_spn_name"));

// Get the contract from the ICalculator interface (not shown here).
// See the sample applications for an example of the ICalculator.
ContractDescription contract = ContractDescription.GetContract(
    typeof(ICalculator));

// Create a new ServiceEndpoint.
ServiceEndpoint se = new ServiceEndpoint(contract, binding, ea);

// Add the service endpoint to the service.
myServiceHost.Description.Endpoints.Add(se);

// Open the service.
myServiceHost.Open();
Console.WriteLine("Listening...");
Console.ReadLine();

// Close the service.
myServiceHost.Close();

설명

이 ID를 사용하여 엔드포인트에 연결하는 보안 WCF 클라이언트는 엔드포인트로 SSPI 인증을 수행할 때 SPN을 사용합니다.

이 정적 메서드는 입력 매개 변수로 사용하여 생성자를 SpnEndpointIdentity호출하여 spnName 인스턴스 SpnEndpointIdentity 를 만듭니다.

빈 문자열로 지정된 경우 가능하면 spnName 인증이 Kerberos에서 NTLM으로 대체됩니다. 이 false경우 AllowNtlm 인증이 실패합니다.

적용 대상