Compartilhar via


ServiceCredentials.WindowsAuthentication Propriedade

Definição

Obtém as configurações de autenticação Windows atuais desse serviço.

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

Valor da propriedade

WindowsServiceCredential

Uma instância de WindowsServiceCredential.

Exemplos

O código a seguir mostra como usar essa propriedade para obter a instância da credencial usada pelo serviço.

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

Comentários

Use essa classe para especificar se deseja permitir o acesso de usuários anônimos Windows definindo a AllowAnonymousLogons propriedade. Além disso, use essa classe para especificar se deve incluir informações de grupo às quais os usuários pertencem AuthorizationContext definindo a IncludeWindowsGroups propriedade.

Aplica-se a