次の方法で共有


ServiceCredentials.WindowsAuthentication プロパティ

定義

このサービスの現在の Windows 認証設定を取得します。

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

プロパティ値

WindowsServiceCredential

WindowsServiceCredential のインスタンス。

このプロパティを使用して、サービスが使用する資格情報のインスタンスを取得する方法を次のコードに示します。

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

注釈

このクラスを使用して、AllowAnonymousLogons プロパティの設定によって匿名の Windows ユーザーのアクセスを許可するかどうかを指定します。 また、ユーザーが属するグループの情報を AuthorizationContext プロパティの設定によって IncludeWindowsGroups に含めるかどうかも指定できます。

適用対象