Search code examples
c#wcfsilverlightwcf-ria-serviceswindows-authentication

How do I access username on the server side using Windows authentication on a WCF service?


I have Silverlight application with a WCF service using Windows Authentication. My users get authenticated correctly. And I can access their username and roles on client side. But how do I do the same thing on server side? I've tried this

ServiceSecurityContext.Current.WindowsIdentity

and

IIdentity caller = ServiceSecurityContext.Current.PrimaryIdentity;

It is what I found as an answer on a similar question here on stackoverflow but it doesn't compile. I get a 'ServiceSecurityContext does not contain definition for Current' exception.

So how do I get the user on server side?


Solution

  • try

    HttpContext.Current.User;
    

    Hope this helps