Share via


WindowsServiceCredential.AllowAnonymousLogons プロパティ

定義

匿名ユーザーのアクセスを許可するかどうかを示す値を取得または設定します (メッセージ レベルのセキュリティのみに適用されます)。

public:
 property bool AllowAnonymousLogons { bool get(); void set(bool value); };
public bool AllowAnonymousLogons { get; set; }
member this.AllowAnonymousLogons : bool with get, set
Public Property AllowAnonymousLogons As Boolean

プロパティ値

匿名ユーザーのアクセスを許可する場合は true、それ以外の場合は false。 既定値は、false です。

このプロパティを取得する方法を次のコードに示します。

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

注釈

バインディングで Windows クライアントの資格情報を使用する場合、既定では匿名アクセスは許可されません。 つまり、ドメインまたはワークグループの認証済みユーザーだけがシステムへのアクセスを許可されます。 しかし、場合によっては、認証されていない匿名のユーザーにサービスへのアクセスを許可できることもあります。 その場合は、このプロパティを true に設定して、匿名クライアントにサービスの呼び出しを許可します。 匿名認証を有効にするサービスではセキュリティ要件が大幅に低下するため、この設定は慎重に使用する必要があります。

このプロパティはトランスポート セキュリティのシナリオには適用されず、基になるバインディングがメッセージ セキュリティを使用してメッセージをセキュリティ保護している場合にのみ適用されます。 Windows トランスポート セキュリティが使用されている場合、このプロパティは適用されません。

適用対象