Looking for a little advice (or maybe even a direct answer).
I have an MVC3 website. I also have a set of WCF services running (for now everything is on the same box).
What I'm trying to do is authenticate the client (that part is working fine), then pass that authenticated user on to various WCF calls.
At the moment I've hooked up the Application_AuthenticateRequest()
method in Global.Asax
, which boils down to creating a new GenericIdentity & GenericPrincipal
, then assigning that principal to HttpContext.Current.User
:
...
GenericIdentity identity = new GenericIdentity(userName);
GenericPrincipal principal = new GenericPrincipal(identity, null);
HttpContext.Current.User = principal;
...
And that part seems to be working fine as well.
But when I hit my service, I have completely lost the user that I set. The values are empty or false.
The one main thing I've noticed is that on the Client side, the HttpContext.Current.User.Identity
object is of type {System.Web.Security.FormsIdentity}
, but in the service it's of type {System.Security.Principal.WindowsIdentity}
.
Based on some of what I've read, it sounds like simply modifying my web.config
so it contains aspNetCompatibilityEnabled="true"
may be enough to make this work properly. But that's not what I'm seeing. So either I'm not understanding everything (a very good possibility) or I've got something screwed up (another good possibility).
So my question. Is this even possible, and if so - thoughts on what I'm missing? I notice a few others have posted something similar but have never quite received a definite answer (see here and here).
Any suggestions are very much appreciated.