ServiceCredentials.WindowsAuthentication Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets the current Windows authentication settings for this service.
public:
property System::ServiceModel::Security::WindowsServiceCredential ^ WindowsAuthentication { System::ServiceModel::Security::WindowsServiceCredential ^ get(); };
public System.ServiceModel.Security.WindowsServiceCredential WindowsAuthentication { get; }
member this.WindowsAuthentication : System.ServiceModel.Security.WindowsServiceCredential
Public ReadOnly Property WindowsAuthentication As WindowsServiceCredential
Property Value
A WindowsServiceCredential instance.
Examples
The following code shows how to use this property to get the instance of the credential used by the service.
// Create a service host.
Uri httpUri = new Uri("http://localhost/Calculator");
ServiceHost sh = new ServiceHost(typeof(Calculator), httpUri);
// Create a binding that uses a WindowsServiceCredential.
WSHttpBinding b = new WSHttpBinding(SecurityMode.Message);
b.Security.Message.ClientCredentialType = MessageCredentialType.Windows;
// Add an endpoint.
sh.AddServiceEndpoint(typeof(ICalculator), b, "WindowsCalculator");
// Get a reference to the WindowsServiceCredential object.
WindowsServiceCredential winCredential =
sh.Credentials.WindowsAuthentication;
// Print out values.
Console.WriteLine("IncludeWindowsGroup: {0}",
winCredential.IncludeWindowsGroups);
Console.WriteLine("UserNamePasswordValidationMode: {0}",
winCredential.AllowAnonymousLogons);
Console.ReadLine();
' Create a service host.
Dim httpUri As New Uri("http://localhost/Calculator")
Dim sh As New ServiceHost(GetType(Calculator), httpUri)
' Create a binding that uses a WindowsServiceCredential.
Dim b As New WSHttpBinding(SecurityMode.Message)
b.Security.Message.ClientCredentialType = MessageCredentialType.Windows
' Add an endpoint.
sh.AddServiceEndpoint(GetType(ICalculator), b, "WindowsCalculator")
' Get a reference to the WindowsServiceCredential object.
Dim winCredential As WindowsServiceCredential = sh.Credentials.WindowsAuthentication
' Print out values.
Console.WriteLine("IncludeWindowsGroup: {0}", winCredential.IncludeWindowsGroups)
Console.WriteLine("UserNamePasswordValidationMode: {0}", winCredential.AllowAnonymousLogons)
Console.ReadLine()
Remarks
Use this class to specify whether to allow anonymous Windows users access by setting the AllowAnonymousLogons property. Also, use this class to specify whether to include a group information to which users belong in the AuthorizationContext by setting the IncludeWindowsGroups property.
Applies to
Commentaires
https://aka.ms/ContentUserFeedback.
Bientôt disponible : Tout au long de 2024, nous allons supprimer progressivement GitHub Issues comme mécanisme de commentaires pour le contenu et le remplacer par un nouveau système de commentaires. Pour plus d’informations, consultezEnvoyer et afficher des commentaires pour