EndpointIdentity.CreateSpnIdentity(String) Metod
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Skapar en SPN-identitet (serverhuvudnamn) med ett angivet namn.
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
Parametrar
- spnName
- String
Namnet på SPN-identiteten.
Returer
Ett SPN EndpointIdentity som är associerat med den angivna spnName.
Undantag
spnName är null.
Exempel
Följande kod visar hur du anropar den här metoden.
// 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();
Kommentarer
En säker WCF-klient som ansluter till en slutpunkt med den här identiteten använder SPN när du utför SSPI-autentisering med slutpunkten.
Den här statiska metoden skapar en instans av genom att anropa konstruktorn, SpnEndpointIdentity, med hjälp SpnEndpointIdentity av spnName som indataparameter.
Om spnName anges med en tom sträng återgår autentiseringen från Kerberos till NTLM om möjligt. Om AllowNtlm är falsemisslyckas autentiseringen.