开发者

Get Identity when calling WCF service from Silverlight app authenticated with Forms auth

开发者 https://www.devze.com 2022-12-08 16:56 出处:网络
I\'m doing FormsAuthentivcation, on a Silverlight app. When the SL app calls a WCF service I\'m trying to get the authenticated username from within my WCF service like this:

I'm doing FormsAuthentivcation, on a Silverlight app. When the SL app calls a WCF service I'm trying to get the authenticated username from within my WCF service like this:

 ServiceSecurityContext.Current.PrimaryIdentity.Name;

or this (unsure of which to use, problem is that both are empty)

ServiceSecurityContext.Anonymous.PrimaryIdentity.Name;

I'm configured the wcf service with a binding like this:

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

Problem i开发者_如何学运维s that I'm unable to get the Identity. I'm not setting the Credentials manually in the client. proxy.ClientCredentials.UserName.UserName="slkfslkdf"; (do I have to do that?)

Thanks for any help!


This is simply solved by HttpContext.Current.User; No need to go into custom headers or the ServiceSecurityContext when doing forms auth.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号