views:

97

answers:

2

I have a WCF service that has a method to return the Windows Username of a Silverlight client that is consuming the service . The WCF service is using basicHttpBinding with the TransportCredentialOnly mode set and the TransportClientCredentialType set to Windows. In IIS Windows authentication is enabled and anon authentication disabled.

Despite (apparently) configuring the service correctly when I call the service and ask it to return the username it errors. Closer examination shows that HttpContext.Current.User is always null (so a nullreferenceexception is thrown).

Does anyone have any other ideas why this is not working?

+2  A: 

Try adding -

<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

to your config file

CraigS
That worked thanks! Also worth noting that you also need to add [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)] to your class as well
Calanus
+1  A: 

In WCF, there is the OperationContext object from which you can retrieve the security credentials passed in by the caller/client by using the ServiceSecurityContext property.

Darin Dimitrov