具有 WCF 服务的 AspNetMembership 提供商

发布于 2024-08-28 03:13:16 字数 1796 浏览 8 评论 0原文

我正在尝试将 AspNetMembershipProvider 配置为用于在使用 basicHttpBinding 的 WCF 服务中进行身份验证。我有以下配置:

<system.serviceModel>
  <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
  <bindings>
    <basicHttpBinding>
      <binding name="basicSecureBinding">
        <security mode="Message"></security>
      </binding>
    </basicHttpBinding>
  </bindings>
  <behaviors>
      <serviceBehaviors>      
        <behavior name="MyApp.Services.ComputersServiceBehavior">
          <serviceAuthorization roleProviderName="AspNetSqlRoleProvider" principalPermissionMode="UseAspNetRoles" />
          <serviceCredentials>
            <userNameAuthentication userNamePasswordValidationMode="MembershipProvider" membershipProviderName="AspNetSqlMembershipProvider"/>
          </serviceCredentials>
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>

      </serviceBehaviors>
  </behaviors>
  <services>
      <service behaviorConfiguration="MyApp.Services.ComputersServiceBehavior" name="MyApp.Services.ComputersService">
          <endpoint binding="basicHttpBinding" contract="MyApp.Services.IComputersService" />
          <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
  </services>
</system.serviceModel>

启用角色并配置成员资格提供程序(其适用于网站)。

但身份验证过程根本没有被触发。请求期间没有对数据库的调用,当我尝试在方法上设置以下属性时:

 [PrincipalPermission(SecurityAction.Demand, Authenticated = true)]
 public bool Test()
 {
     return true;
 }

我收到访问被拒绝的异常。有什么想法如何解决它吗?

I'm trying to configure AspNetMembershipProvider to be used for authenticating in my WCF service that is using basicHttpBinding. I have following configuration:

<system.serviceModel>
  <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
  <bindings>
    <basicHttpBinding>
      <binding name="basicSecureBinding">
        <security mode="Message"></security>
      </binding>
    </basicHttpBinding>
  </bindings>
  <behaviors>
      <serviceBehaviors>      
        <behavior name="MyApp.Services.ComputersServiceBehavior">
          <serviceAuthorization roleProviderName="AspNetSqlRoleProvider" principalPermissionMode="UseAspNetRoles" />
          <serviceCredentials>
            <userNameAuthentication userNamePasswordValidationMode="MembershipProvider" membershipProviderName="AspNetSqlMembershipProvider"/>
          </serviceCredentials>
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>

      </serviceBehaviors>
  </behaviors>
  <services>
      <service behaviorConfiguration="MyApp.Services.ComputersServiceBehavior" name="MyApp.Services.ComputersService">
          <endpoint binding="basicHttpBinding" contract="MyApp.Services.IComputersService" />
          <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
  </services>
</system.serviceModel>

Roles are enabled and membership provider is configured (its working for web site).

But authentication process is not fired at all. There is no calles to data base during request, and when I try to set following attribute on method:

 [PrincipalPermission(SecurityAction.Demand, Authenticated = true)]
 public bool Test()
 {
     return true;
 }

I'm getting access denied exception. Any thoughts how to fix it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

愿与i 2024-09-04 03:13:16

尝试一下CodePlex 安全指南操作方法应用场景 提供了许多配置选项的详细设置和配置指南,可以帮助您找到拼图中缺失的部分。

Try this CodePlex Security Guide, the How Tos and Application Scenarios have detailed setup and configurations guides for a number of configuration options that might help you find the missing piece of your puzzle.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文