【问题标题】:Get Identity when calling WCF service from Silverlight app authenticated with Forms auth从使用 Forms auth 进行身份验证的 Silverlight 应用程序调用 WCF 服务时获取身份
【发布时间】:2009-10-19 09:43:36
【问题描述】:

我正在使用 Silverlight 应用程序进行 FormsAuthentivcation。当 SL 应用程序调用 WCF 服务时,我试图从我的 WCF 服务中获取经过身份验证的用户名,如下所示:

 ServiceSecurityContext.Current.PrimaryIdentity.Name;

或this(不确定使用哪个,问题是两者都是空的)

ServiceSecurityContext.Anonymous.PrimaryIdentity.Name;

我使用这样的绑定配置了 wcf 服务:

   <basicHttpBinding>
     <binding name="myBinding">
       <security mode="None">
         <message clientCredentialType="UserName"/>
       </security>
     </binding>

问题是我无法获得身份。我没有在客户端中手动设置凭据。 proxy.ClientCredentials.UserName.UserName="slkfslkdf"; (我必须这样做吗?)

感谢您的帮助!

【问题讨论】:

    标签: wcf silverlight authentication


    【解决方案1】:

    HttpContext.Current.User; 可以轻松解决这个问题,在进行表单身份验证时无需进入自定义标头或 ServiceSecurityContext。

    【讨论】:

      猜你喜欢
      • 2010-11-08
      • 1970-01-01
      • 2011-05-01
      • 2014-07-04
      • 2011-02-12
      • 1970-01-01
      • 2012-11-20
      • 2012-07-27
      • 1970-01-01
      相关资源
      最近更新 更多