It seems that the technique presented in this video works well even in WCF data services. You create your own subclass of ServiceAuthorizationManager (see MSDN ), override CheckAccessCore() and register it in web.config.
I got it to work by passing the key in the HTTP request header. OperationContext passed to CheckAccessCore you from capturing the headers of the HTTP request , but you can get them through HttpContext.Current.Request.Headers . Then you can get the correct title from this collection and check it out, but you need to.
Here is the required registration in web.config:
<system.serviceModel> <behaviors> <serviceBehaviors> <behavior> <serviceAuthorization serviceAuthorizationManagerType="FullyQualifiedTypeNameHere, ProjectNameHere" /> </behavior> </serviceBehaviors> </behaviors>
UPDATE: I was wrong in getting the headers from HttpContext.Current.Request.Headers ; HttpContext.Current is null when working in IIS (but interestingly not when debugging). Instead, use WebOperationContext.Current.IncomingRequest.Headers in accordance with this question .
UPDATE 2: HttpContext.Current is null if you are not using WCF in ASP.NET compatibility mode. You can enable this by adding the following line to the application-level web.config in the system.serviceModel node:
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
Also add this above to your service implementation if you have a vanilla WCF service that works in addition to the ADO.NET service:
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
Then you can get HttpContext.Current.Request.Headers and all the other things provided by the HttpRequest .
source share