1
<system.web> 
    <compilation debug="true" 
       targetFramework="4.0" /> 
    <httpRuntime requestPathInvalidCharacters="" /> 
    <authentication mode="Forms" /> 
    <membership defaultProvider="> 
     <providers> 
      <clear /> 
       <add name="ANSMP" 
        type="Test.Authentication.CustomMembershipProvider" 
        connectionStringName="DataConnection" /> 
     </providers> 
    </membership> 
    <roleManager enabled="true" 
       defaultProvider="ANSRP"> 
     <providers > 
      <clear />  
       <add connectionStringName="DataConnection" 
        applicationName="/" 
        name="ANSRP" 
        type="Test.Authentication.CustomRoleProvider" /> 
     </providers> 
    </roleManager> 
</system.web> 
<system.serviceModel> 
    <behaviours> 
     <serviceBehaviors> 
      <behavior name="TestDataBehaviour"> 
       <serviceCredentials> 
        <userNameAuthentication userNamePasswordValidationMode="MembershipProvider" 
              membershipProviderName="ANSMP"/> 
       </serviceCredentials> 
       <serviceMetadata httpGetEnabled="true" 
           httpsGetEnabled="true" /> 
       <serviceAuthorization principalPermissionMode="UseAspNetRoles" 
             roleProviderName="ANSRP" /> 
       <dataContractSerializer ignoreExtensionDataObject="true" /> 
       <serviceDebug httpHelpPageBinding="webHttpBinding" 
           httpHelpPageBindingConfiguration="" 
           includeExceptionDetailInFaults="true" /> 
      </behavior> 
     </serviceBehaviour> 
    </behaviors> 
</system.serviceModel> 

不触发假设我离开我的自定义成员资格提供程序和自定义角色providwer空(莘,所有的方法throw NotImplementedException);我希望一个错误,当我尝试检查使用[PrinciplePermission(SecurityAction.Demand, Role = "Custom")]var b = Thread.CurrentPrincipal.IsInRole("Custom")]自定义角色提供web服务中

但是相反,它只是不断在球场上恢复Access is denied(在属性)和false的作用。

使用Membership.GetAllUsers()实际上确实给了我一个NotImplementedError ..但我如何确保在使用PrincipalPermission属性时触发我的自定义角色提供程序和自定义成员资格提供程序?

编辑

我已经尝试添加, Test.Authentication的成员提供的类型以及角色提供...

但是目前PrinciplePermission告诉我Request for principal permission failed

编辑2

当检查我的跟踪日志时,我发现以下内容:

The action that failed was: 
Demand 
The type of the first permission that failed was: 
System.Security.Permissions.PrincipalPermission 
The first permission that failed was: 
<IPermission class="System.Security.Permissions.PrincipalPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" 
version="1"> 
<Identity Authenticated="true" 
Role="Customer"/> 
</IPermission> 

The demand was for: 
<IPermission class="System.Security.Permissions.PrincipalPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" 
version="1"> 
<Identity Authenticated="true" 
Role="Customer"/> 
</IPermission> 

The assembly or AppDomain that failed was: 
mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 

我也得到一个公平的几个Extension type not found警告

<TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Warning"> 
    <TraceIdentifier>http://msdn.microsoft.com/nl-NL/library/System.ServiceModel.ExtensionTypeNotFound.aspx</TraceIdentifier> 
    <Description>Extension type not found.</Description> 
    <AppDomain>/LM/W3SVC/1/ROOT/webapi3-6-130082517071825580</AppDomain> 
    <ExtendedData xmlns="http://schemas.microsoft.com/2006/08/ServiceModel/DictionaryTraceRecord"> 
     <ExtensionName>pollingDuplexHttpBinding</ExtensionName> 
     <ExtensionType>System.ServiceModel.Configuration.PollingDuplexHttpBindingCollectionElement, System.ServiceModel.PollingDuplex, version=3.0.0.0, Culture=neutral</ExtensionType> 
    </ExtendedData> 
</TraceRecord> 

回答

0

大量的时间后,我发现,上面显示每个人的作品corretly

从客户端,当你创建一个服务参考,2个端点(在我们的例子中)。我不知道这是否是标准)。 一个是安全的,一个是..好吧,没有安全。

对于使用令牌我总是使用非安全的...但为了使用成员资格提供者,角色提供者和用户名密码验证我需要使用安全的终点!

相关问题