Condividi tramite


ServiceCredentials.WindowsAuthentication Proprietà

Definizione

Ottiene le impostazioni correnti dell'autenticazione di Windows per il servizio.

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

Valore della proprietà

WindowsServiceCredential

Istanza di WindowsServiceCredential.

Esempio

Nel codice seguente viene illustrato come utilizzare questa proprietà per l'istanza delle credenziali utilizzate dal servizio.

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

Commenti

Utilizzare questa classe per specificare se consentire l'accesso a utenti di Windows anonimi impostando la proprietà AllowAnonymousLogons. Utilizzare questa classe per specificare inoltre se includere le informazioni di un gruppo a cui appartengono gli utenti in AuthorizationContext impostando la proprietà IncludeWindowsGroups.

Si applica a