我正在使用Silverlight应用程序进行FormsAuthentivcation。当SL应用程序调用WCF服务时,我试图从我的WCF服务中获取经过身份验证的用户名,如下所示:
ServiceSecurityContext.Current.PrimaryIdentity.Name;
或者这个(不确定使用哪个,问题是两者都是空的)
ServiceSecurityContext.Anonymous.PrimaryIdentity.Name;
我使用这样的绑定配置了wcf服务:
<basicHttpBinding>
<binding name="myBinding">
<security mode="None">
<message clientCredentialType="UserName"/>
</security>
</binding>
问题是我无法获得身份。我没有在客户端中手动设置凭据。 proxy.ClientCredentials.UserName.UserName = “slkfslkdf”; (我必须这样做吗?)
感谢您的帮助!
答案 0 :(得分:0)
这可以通过HttpContext.Current.User;
简单地解决。在执行表单身份验证时无需进入自定义标头或ServiceSecurityContext。