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使用する場合、このプロパティは適用されません。

適用対象