承载自定义WCF服务与内部一把umbraco认证 [英] Host custom WCF service with authentication within Umbraco

查看:144
本文介绍了承载自定义WCF服务与内部一把umbraco认证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建内一把umbraco自定义WCF服务。该服务驻留在服务文件夹,似乎是工作的罚款(我可以调用它,它适当的反应)。现在,我希望用户,当他们拨打服务验证自己的身份。

I've created a custom WCF service within Umbraco. The service resides in the Service folder and seems to be working fine (I can call it and it responds appropriately). Now I want the users to authenticate themselves when they call the service.

要做到这一点,我已经添加了这些行到的web.config

To do this I've added these lines into the web.config:

<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />
 <bindings>
  <webHttpBinding>
    <binding name="RaceManBinding">
      <security mode="None" />
    </binding>
  </webHttpBinding>
</bindings>
<services>
  <service name="RaceManagerAdmin.RaceManDataService" behaviorConfiguration="RaceManBehavior">

    <endpoint address=""
              binding="webHttpBinding"
              contract="System.Data.Services.IRequestHandler" />
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="RaceManBehavior">
      <serviceCredentials>
        <userNameAuthentication userNamePasswordValidationMode="MembershipProvider"
                                membershipProviderName="UmbracoMembershipProvider" />
      </serviceCredentials>
    </behavior>
  </serviceBehaviors>
</behaviors>
</system.serviceModel>

在我的服务被称为它应该使用一把umbraco成员提供对用户进行验证。

When my service is called it should use the Umbraco membership provider to authenticate the users.

我的客户创建一个网络凭证的对象,像这样specificies这样的:

My client specificies this by creating a network credential object, like this:

var a = new RaceEntities(new Uri("http://localhost:40406/umbraco/Webservices/RaceManDataService.svc")) { Credentials = new NetworkCredential("admin", "secret") };

当我检查 HTTPContext.Current 我没有看到任何身份验证的用户。

When I inspect the HTTPContext.Current I don't see any authenticated users.

我在做什么错了?

弗雷德里克

推荐答案

您需要启用ASP.Net的兼容性,以便通过HttpContext的访问身份:

You'll need to enable ASP.Net Compatibility in order to access the identity via the HttpContext:

<system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
</system.serviceModel>

在回答这个问题提到了另一种方法:<一href=\"http://stackoverflow.com/questions/6747263/how-to-access-httpcontext-current-user-username-in-wcf-service\">How访问HttpContext.Current.User.Username在WCF服务

这篇关于承载自定义WCF服务与内部一把umbraco认证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆