EndpointIdentity.CreateSpnIdentity(String) Método

Definición

Crea una identidad de nombre de entidad de seguridad de servidor (SPN) con un nombre especificado.Creates a server principal name (SPN) identity with a specified name.

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

Parámetros

spnName
String

Nombre para la identidad SPN.The name for the SPN identity.

Devoluciones

EndpointIdentity

SPN EndpointIdentity asociado al spnName especificado.An SPN EndpointIdentity associated with the specified spnName.

Excepciones

spnName es null.spnName is null.

Ejemplos

El siguiente código muestra cómo llamar a este método.The following code shows how to call this method.

// 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();

Comentarios

Un cliente WCF seguro que se conecta a un punto de conexión con esta identidad usa el SPN al realizar la autenticación SSPI con el punto de conexión.A secure WCF client that connects to an endpoint with this identity uses the SPN when performing SSPI authentication with the endpoint.

Este método estático crea una instancia de SpnEndpointIdentity llamando a su constructor, SpnEndpointIdentity, utilizando spnName como parámetro de entrada.This static method creates an instance of SpnEndpointIdentity by calling its constructor, SpnEndpointIdentity, using spnName as the input parameter.

Si spnName se especifica con una cadena vacía, la autenticación se retirará de Kerberos a NTLM si es posible.If spnName is specified with an empty string, authentication falls back from Kerberos to NTLM if possible. Si AllowNtlm es false, se produce un error de autenticación.If AllowNtlm is false, authentication fails.

Se aplica a