ServiceAuthorizationBehavior.PrincipalPermissionMode 属性

定义

获取或设置主体权限模式。

public:
 property System::ServiceModel::Description::PrincipalPermissionMode PrincipalPermissionMode { System::ServiceModel::Description::PrincipalPermissionMode get(); void set(System::ServiceModel::Description::PrincipalPermissionMode value); };
public System.ServiceModel.Description.PrincipalPermissionMode PrincipalPermissionMode { get; set; }
member this.PrincipalPermissionMode : System.ServiceModel.Description.PrincipalPermissionMode with get, set
Public Property PrincipalPermissionMode As PrincipalPermissionMode

属性值

主体权限模式。

示例

此代码演示如何设置此属性。

ServiceHost myServiceHost = new ServiceHost(typeof(Calculator), baseUri);
ServiceAuthorizationBehavior myServiceBehavior =
    myServiceHost.Description.Behaviors.Find<ServiceAuthorizationBehavior>();
myServiceBehavior.PrincipalPermissionMode =
    PrincipalPermissionMode.UseAspNetRoles;
Dim myServiceBehavior As ServiceAuthorizationBehavior
myServiceBehavior = _
   myServiceHost.Description.Behaviors.Find(Of ServiceAuthorizationBehavior)()
myServiceBehavior.PrincipalPermissionMode = _
   PrincipalPermissionMode.UseAspNetRoles

注解

此属性包含 PrincipalPermissionMode 枚举的成员之一。 有效值是:

  • Custom. 自定义 IAuthorizationPolicy 实现用于填充 Thread.CurrentPrincipal

  • None. 未设置 Thread.CurrentPrincipal 属性。

  • UseAspNetRoles. 根据 ASP.NET 角色信息将 Thread.CurrentPrincipal 属性设置为 IPrincipal

  • UseWindowsGroups. 根据传入消息的用户凭据,将 Thread.CurrentPrincipal 属性设置为 WindowsPrincipal

适用于

另请参阅